-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/appany/AppAny.HotChocolate.…
…FluentValidation into main
- Loading branch information
Showing
14 changed files
with
143 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace AppAny.HotChocolate.FluentValidation | ||
{ | ||
public sealed class SkipValidationAttribute : FluentValidationAttribute | ||
public class SkipValidationAttribute : FluentValidationAttribute | ||
{ | ||
public override void Configure(ArgumentValidationBuilder builder) | ||
public sealed override void Configure(ArgumentValidationBuilder builder) | ||
{ | ||
builder.SkipValidation(); | ||
builder.SkipValidation(SkipValidation); | ||
} | ||
|
||
public virtual ValueTask<bool> SkipValidation(SkipValidationContext skipValidationContext) | ||
{ | ||
return ValidationDefaults.SkipValidation.Skip(skipValidationContext); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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
33 changes: 33 additions & 0 deletions
33
...olate.FluentValidation.Tests/Core/Mutations/Attribute/TestCustomSkipValidationMutation.cs
This file contains 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,33 @@ | ||
using System.Threading.Tasks; | ||
using HotChocolate.Types; | ||
|
||
namespace AppAny.HotChocolate.FluentValidation.Tests | ||
{ | ||
public class CustomSkipValidationAttribute : SkipValidationAttribute | ||
{ | ||
public const string SkipName = "Custom"; | ||
|
||
public override ValueTask<bool> SkipValidation(SkipValidationContext skipValidationContext) | ||
{ | ||
var argumentValue = skipValidationContext | ||
.MiddlewareContext | ||
.ArgumentValue<TestPersonInput>(skipValidationContext.Argument.Name); | ||
|
||
return new ValueTask<bool>(argumentValue.Name == SkipName); | ||
} | ||
} | ||
|
||
public class TestCustomSkipValidationMutation : ObjectType | ||
{ | ||
protected override void Configure(IObjectTypeDescriptor descriptor) | ||
{ | ||
descriptor.Field<TestCustomSkipValidationMutation>( | ||
field => field.Test(default!)).Type<StringType>(); | ||
} | ||
|
||
public string Test([UseFluentValidation, CustomSkipValidation] TestPersonInput input) | ||
{ | ||
return "test"; | ||
} | ||
} | ||
} |
This file contains 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 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