-
-
Notifications
You must be signed in to change notification settings - Fork 158
JADNC: Required Input validation disabled for partial patching / relationships #781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bart-degreed
merged 27 commits into
json-api-dotnet:master
from
sasman0001:input_validation_disable_validators
Jun 16, 2020
Merged
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c4c27aa
disable validator if partial patch
sasman0001 ead6930
Create required validator that can be diabled to allow for partial pa…
sasman0001 a4c688d
formatting
sasman0001 7d3f57a
Remove unneeded reference.
sasman0001 11bd7d9
package reference
sasman0001 c02ef34
Requested changes:
sasman0001 9e40b88
Add version wildcard
sasman0001 a0de349
expect possible null in HttpContextExtension method
sasman0001 86989e6
change parameter order and naming for consistency
sasman0001 50ae2e4
Requested changes
sasman0001 102e636
Remove unneeded null check.
sasman0001 3917539
add null checks
sasman0001 cfbc9e3
generate fake name for author
sasman0001 0bcebe3
Moved logic to RequestDeserializer, overriding methods in BaseDocumen…
sasman0001 6a682ed
remove references
sasman0001 c2f2a69
formatting
sasman0001 81e764e
back to var
sasman0001 126a1a8
Requested changes:
sasman0001 a1596d5
formatting
sasman0001 d82f193
formatting
sasman0001 6882b19
change access modifiers
sasman0001 96cbd84
Requested changes:
sasman0001 945691d
refactor
sasman0001 4496d72
remoev comma.
sasman0001 4bc23b7
Merge remote-tracking branch 'upstream/master' into input_validation_…
sasman0001 7eeb6c5
Cleanup
44a9d92
removed unneeded code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ | |
<BogusVersion>29.0.1</BogusVersion> | ||
<MoqVersion>4.13.1</MoqVersion> | ||
</PropertyGroup> | ||
</Project> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using JsonApiDotNetCore.Extensions; | ||
|
||
namespace JsonApiDotNetCore.Models | ||
{ | ||
public sealed class IsRequiredAttribute : RequiredAttribute | ||
{ | ||
private bool _isDisabled; | ||
|
||
public override bool IsValid(object value) | ||
{ | ||
return _isDisabled || base.IsValid(value); | ||
} | ||
|
||
protected override ValidationResult IsValid(object value, ValidationContext validationContext) | ||
{ | ||
var httpContextAccessor = (IHttpContextAccessor)validationContext.GetRequiredService(typeof(IHttpContextAccessor)); | ||
_isDisabled = httpContextAccessor.HttpContext.IsValidatorDisabled(validationContext.MemberName, validationContext.ObjectType.Name); | ||
return _isDisabled ? ValidationResult.Success : base.IsValid(value, validationContext); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can inherit from the non-generic Identifiable, which is easier to understand for newcomers (see my example). Also this is a nice opportunity to show usage of the AllowEmptyStrings parameter so users will know it exists. Can you use my example from earlier comments instead?Never mind, I'll change this.