Skip to content

Commit

Permalink
Extract steps (#73)
Browse files Browse the repository at this point in the history
* Add nested Steps type

* Run full cleanup
  • Loading branch information
sergeyshaykhullin authored May 20, 2021
1 parent 6fb73b4 commit aa2eaef
Show file tree
Hide file tree
Showing 34 changed files with 225 additions and 212 deletions.
4 changes: 2 additions & 2 deletions src/Attributes/UseFluentValidationAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
namespace AppAny.HotChocolate.FluentValidation
{
/// <summary>
/// Use default validation options.
/// To override options use Code-first approach <see cref="ArgumentDescriptorExtensions"/>
/// Use default validation options.
/// To override options use Code-first approach <see cref="ArgumentDescriptorExtensions" />
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class UseFluentValidationAttribute : ArgumentDescriptorAttribute
Expand Down
2 changes: 1 addition & 1 deletion src/Builders/ArgumentValidationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace AppAny.HotChocolate.FluentValidation
{
/// <summary>
/// Configures input field validation options
/// Configures input field validation options
/// </summary>
public interface ArgumentValidationBuilder
: CanSkipValidation<ArgumentValidationBuilder>,
Expand Down
2 changes: 1 addition & 1 deletion src/Builders/Core/CanSkipValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace AppAny.HotChocolate.FluentValidation
public interface CanSkipValidation<TBuilder>
{
/// <summary>
/// Implementation specific. Can add or override <see cref="SkipValidation"/>
/// Implementation specific. Can add or override <see cref="SkipValidation" />
/// </summary>
TBuilder SkipValidation(SkipValidation skipValidation);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Builders/Core/CanUseErrorMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace AppAny.HotChocolate.FluentValidation
public interface CanUseErrorMapper<TBuilder>
{
/// <summary>
/// Implementation specific. Can add or override <see cref="MapError"/>
/// Implementation specific. Can add or override <see cref="MapError" />
/// </summary>
TBuilder UseErrorMapper(MapError errorMapper);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Builders/Core/CanUseInputValidators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace AppAny.HotChocolate.FluentValidation
public interface CanUseInputValidators<TBuilder>
{
/// <summary>
/// Implementation specific. Can add or override <see cref="ValidateInput"/>
/// Implementation specific. Can add or override <see cref="ValidateInput" />
/// </summary>
TBuilder UseInputValidators(params ValidateInput[] inputValidators);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Builders/Extensions/UseValidationStrategyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AppAny.HotChocolate.FluentValidation
public static class UseValidationStrategyExtensions
{
/// <summary>
/// Overrides <see cref="ValidationStrategy{T}"/>.
/// Overrides <see cref="ValidationStrategy{T}" />.
/// </summary>
public static ArgumentValidationBuilder UseValidationStrategy(
this ArgumentValidationBuilder builder,
Expand All @@ -16,7 +16,7 @@ public static ArgumentValidationBuilder UseValidationStrategy(
}

/// <summary>
/// Overrides <see cref="ValidationStrategy{T}"/>.
/// Overrides <see cref="ValidationStrategy{T}" />.
/// </summary>
public static ArgumentValidationBuilder UseValidationStrategy(
this ArgumentValidationBuilder builder,
Expand All @@ -26,7 +26,7 @@ public static ArgumentValidationBuilder UseValidationStrategy(
}

/// <summary>
/// Overrides <see cref="ValidationStrategy{T}"/>.
/// Overrides <see cref="ValidationStrategy{T}" />.
/// </summary>
public static ArgumentValidationBuilder UseValidationStrategy<TInput>(
this ArgumentValidationBuilder builder,
Expand All @@ -36,17 +36,17 @@ public static ArgumentValidationBuilder UseValidationStrategy<TInput>(
}

/// <summary>
/// Overrides <see cref="ValidationStrategy{T}"/>.
/// Overrides <see cref="ValidationStrategy{T}" />.
/// </summary>
public static ArgumentValidationBuilder UseValidationStrategy<TInput>(
this ArgumentValidationBuilder builder,
Action<InputValidatorContext, ValidationStrategy<TInput>> validationStrategy)
{
return builder.UseInputValidator(
ValidationDefaults.InputValidators.ArgumentValue<TInput>,
ValidationDefaults.InputValidators.ValidationContextWithStrategy(validationStrategy)!,
ValidationDefaults.InputValidators.Steps.ArgumentValue<TInput>,
ValidationDefaults.InputValidators.Steps.ValidationContextWithStrategy(validationStrategy)!,
inputValidatorContext => inputValidatorContext.Argument.GetGenericValidatorType(),
ValidationDefaults.InputValidators.Validators);
ValidationDefaults.InputValidators.Steps.Validators);
}
}
}
28 changes: 14 additions & 14 deletions src/Builders/Extensions/UseValidatorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace AppAny.HotChocolate.FluentValidation
public static class UseValidatorExtensions
{
/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses <see cref="TValidator"/> to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses <see cref="TValidator" /> to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidator<TValidator>(this ArgumentValidationBuilder builder)
where TValidator : class, IValidator
Expand All @@ -16,8 +16,8 @@ public static ArgumentValidationBuilder UseValidator<TValidator>(this ArgumentVa
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses all <see cref="TValidator"/> to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses all <see cref="TValidator" /> to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidators<TValidator>(this ArgumentValidationBuilder builder)
where TValidator : class, IValidator
Expand All @@ -26,33 +26,33 @@ public static ArgumentValidationBuilder UseValidators<TValidator>(this ArgumentV
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidator(
this ArgumentValidationBuilder builder,
Type validatorType)
{
return builder.UseInputValidator(
ValidationDefaults.InputValidators.ArgumentValue<object>,
ValidationDefaults.InputValidators.ValidationContext,
ValidationDefaults.InputValidators.Steps.ArgumentValue<object>,
ValidationDefaults.InputValidators.Steps.ValidationContext,
_ => validatorType,
ValidationDefaults.InputValidators.Validator);
ValidationDefaults.InputValidators.Steps.Validator);
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidators(
this ArgumentValidationBuilder builder,
Type validatorType)
{
return builder.UseInputValidator(
ValidationDefaults.InputValidators.ArgumentValue<object>,
ValidationDefaults.InputValidators.ValidationContext,
ValidationDefaults.InputValidators.Steps.ArgumentValue<object>,
ValidationDefaults.InputValidators.Steps.ValidationContext,
_ => validatorType,
ValidationDefaults.InputValidators.Validators);
ValidationDefaults.InputValidators.Steps.Validators);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace AppAny.HotChocolate.FluentValidation
public static class UseValidatorWithValidationStrategyExtensions
{
/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses <see cref="TValidator"/> to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses <see cref="TValidator" /> to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator<TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -19,8 +19,8 @@ public static ArgumentValidationBuilder UseValidator<TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses <see cref="TValidator"/> to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses <see cref="TValidator" /> to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator<TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -31,8 +31,8 @@ public static ArgumentValidationBuilder UseValidator<TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses all <see cref="TValidator"/> to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses all <see cref="TValidator" /> to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidators<TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -43,8 +43,8 @@ public static ArgumentValidationBuilder UseValidators<TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses all <see cref="TValidator"/> to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses all <see cref="TValidator" /> to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidators<TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -55,8 +55,8 @@ public static ArgumentValidationBuilder UseValidators<TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator(
this ArgumentValidationBuilder builder,
Expand All @@ -67,8 +67,8 @@ public static ArgumentValidationBuilder UseValidator(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator(
this ArgumentValidationBuilder builder,
Expand All @@ -79,8 +79,8 @@ public static ArgumentValidationBuilder UseValidator(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidators(
this ArgumentValidationBuilder builder,
Expand All @@ -91,8 +91,8 @@ public static ArgumentValidationBuilder UseValidators(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidators(
this ArgumentValidationBuilder builder,
Expand All @@ -103,8 +103,9 @@ public static ArgumentValidationBuilder UseValidators(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses <see cref="TValidator"/> to resolve <see cref="ValidateInput"/> with <see cref="ValidationDefaults.ValidationStrategies.Default{TInput}"/> strategy
/// Overrides global <see cref="ValidateInput" />.
/// Uses <see cref="TValidator" /> to resolve <see cref="ValidateInput" /> with
/// <see cref="ValidationDefaults.ValidationStrategies.Default{TInput}" /> strategy
/// </summary>
public static ArgumentValidationBuilder UseValidator<TInput, TValidator>(this ArgumentValidationBuilder builder)
where TValidator : class, IValidator<TInput>
Expand All @@ -113,8 +114,9 @@ public static ArgumentValidationBuilder UseValidator<TInput, TValidator>(this Ar
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses all <see cref="TValidator"/> to resolve <see cref="ValidateInput"/> with <see cref="ValidationDefaults.ValidationStrategies.Default{TInput}"/> strategy
/// Overrides global <see cref="ValidateInput" />.
/// Uses all <see cref="TValidator" /> to resolve <see cref="ValidateInput" /> with
/// <see cref="ValidationDefaults.ValidationStrategies.Default{TInput}" /> strategy
/// </summary>
public static ArgumentValidationBuilder UseValidators<TInput, TValidator>(this ArgumentValidationBuilder builder)
where TValidator : class, IValidator<TInput>
Expand All @@ -123,8 +125,9 @@ public static ArgumentValidationBuilder UseValidators<TInput, TValidator>(this A
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses <see cref="TValidator"/> to resolve <see cref="ValidateInput"/>, with custom <see cref="ValidationStrategy{TInput}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses <see cref="TValidator" /> to resolve <see cref="ValidateInput" />, with custom
/// <see cref="ValidationStrategy{TInput}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator<TInput, TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -135,8 +138,9 @@ public static ArgumentValidationBuilder UseValidator<TInput, TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses <see cref="TValidator"/> to resolve <see cref="ValidateInput"/>, with custom <see cref="ValidationStrategy{TInput}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses <see cref="TValidator" /> to resolve <see cref="ValidateInput" />, with custom
/// <see cref="ValidationStrategy{TInput}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator<TInput, TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -147,8 +151,9 @@ public static ArgumentValidationBuilder UseValidator<TInput, TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses all <see cref="TValidator"/> to resolve <see cref="ValidateInput"/>, with custom <see cref="ValidationStrategy{TInput}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses all <see cref="TValidator" /> to resolve <see cref="ValidateInput" />, with custom
/// <see cref="ValidationStrategy{TInput}" />
/// </summary>
public static ArgumentValidationBuilder UseValidators<TInput, TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -159,8 +164,9 @@ public static ArgumentValidationBuilder UseValidators<TInput, TValidator>(
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses all <see cref="TValidator"/> to resolve <see cref="ValidateInput"/>, with custom <see cref="ValidationStrategy{TInput}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses all <see cref="TValidator" /> to resolve <see cref="ValidateInput" />, with custom
/// <see cref="ValidationStrategy{TInput}" />
/// </summary>
public static ArgumentValidationBuilder UseValidators<TInput, TValidator>(
this ArgumentValidationBuilder builder,
Expand All @@ -170,38 +176,36 @@ public static ArgumentValidationBuilder UseValidators<TInput, TValidator>(
return builder.UseValidators(typeof(TValidator), validationStrategy);
}



/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/> with <see cref="ValidationStrategy{T}"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" /> with <see cref="ValidationStrategy{T}" />
/// </summary>
public static ArgumentValidationBuilder UseValidator<TInput>(
this ArgumentValidationBuilder builder,
Type validatorType,
Action<InputValidatorContext, ValidationStrategy<TInput>> validationStrategy)
{
return builder.UseInputValidator(
ValidationDefaults.InputValidators.ArgumentValue<TInput>,
ValidationDefaults.InputValidators.ValidationContextWithStrategy(validationStrategy)!,
ValidationDefaults.InputValidators.Steps.ArgumentValue<TInput>,
ValidationDefaults.InputValidators.Steps.ValidationContextWithStrategy(validationStrategy)!,
_ => validatorType,
ValidationDefaults.InputValidators.Validator);
ValidationDefaults.InputValidators.Steps.Validator);
}

/// <summary>
/// Overrides global <see cref="ValidateInput"/>.
/// Uses type to resolve <see cref="ValidateInput"/>
/// Overrides global <see cref="ValidateInput" />.
/// Uses type to resolve <see cref="ValidateInput" />
/// </summary>
public static ArgumentValidationBuilder UseValidators<TInput>(
this ArgumentValidationBuilder builder,
Type validatorType,
Action<InputValidatorContext, ValidationStrategy<TInput>> validationStrategy)
{
return builder.UseInputValidator(
ValidationDefaults.InputValidators.ArgumentValue<TInput>,
ValidationDefaults.InputValidators.ValidationContextWithStrategy(validationStrategy)!,
ValidationDefaults.InputValidators.Steps.ArgumentValue<TInput>,
ValidationDefaults.InputValidators.Steps.ValidationContextWithStrategy(validationStrategy)!,
_ => validatorType,
ValidationDefaults.InputValidators.Validators);
ValidationDefaults.InputValidators.Steps.Validators);
}
}
}
Loading

0 comments on commit aa2eaef

Please sign in to comment.