FluentValidation by Jeremy Skinner

<PackageReference Include="FluentValidation" Version="5.6.1" />

 DefaultValidatorOptions

public static class DefaultValidatorOptions
Default options that can be used to configure a validator.
public static IRuleBuilderInitial<T, TProperty> Cascade<T, TProperty>(this IRuleBuilderInitial<T, TProperty> ruleBuilder, CascadeMode cascadeMode)

Specifies the cascade mode for failures. If set to 'Stop' then execution of the rule will stop once the first validator in the chain fails. If set to 'Continue' then all validators in the chain will execute regardless of failures.

public static IRuleBuilderOptions<T, TProperty> DependentRules<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Action<DependentRules<T>> action)

Triggers an action when the rule passes. Typically used to configure dependent rules. This applies to all preceding rules in the chain.

public static IRuleBuilderOptions<T, TProperty> OnAnyFailure<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Action<T> onFailure)

Specifies a custom action to be invoked when the validator fails.

public static IRuleBuilderOptions<T, TProperty> OverridePropertyName<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string propertyName)

Overrides the name of the property associated with this rule. NOTE: This is a considered to be an advanced feature. 99% of the time that you use this, you actually meant to use WithName.

public static IRuleBuilderOptions<T, TProperty> Unless<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Func<T, bool> predicate, ApplyConditionTo applyConditionTo = 0)

Specifies a condition limiting when the validator should not run. The validator will only be executed if the result of the lambda returns false.

public static IRuleBuilderOptions<T, TProperty> When<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Func<T, bool> predicate, ApplyConditionTo applyConditionTo = 0)

Specifies a condition limiting when the validator should run. The validator will only be executed if the result of the lambda returns true.

public static IRuleBuilderOptions<T, TProperty> WithLocalizedMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Expression<Func<string>> resourceSelector)

Specifies a custom error message resource to use when validation fails.

public static IRuleBuilderOptions<T, TProperty> WithLocalizedMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Expression<Func<string>> resourceSelector, object[] formatArgs)

Specifies a custom error message resource to use when validation fails.

public static IRuleBuilderOptions<T, TProperty> WithLocalizedMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Expression<Func<string>> resourceSelector, Func<T, object>[] formatArgs)

Specifies a custom error message resource to use when validation fails.

public static IRuleBuilderOptions<T, TProperty> WithLocalizedMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Expression<Func<string>> resourceSelector, IResourceAccessorBuilder resourceAccessorBuilder)

Specifies a custom error message resource to use when validation fails.

public static IRuleBuilderOptions<T, TProperty> WithLocalizedName<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Expression<Func<string>> resourceSelector, IResourceAccessorBuilder resourceAccessorBuilder = null)

Specifies a localized name for the error message.

public static IRuleBuilderOptions<T, TProperty> WithMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string errorMessage)

Specifies a custom error message to use if validation fails.

public static IRuleBuilderOptions<T, TProperty> WithMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string errorMessage, object[] formatArgs)

Specifies a custom error message to use if validation fails.

public static IRuleBuilderOptions<T, TProperty> WithMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string errorMessage, Func<T, object>[] funcs)

Specifies a custom error message to use if validation fails.

public static IRuleBuilderOptions<T, TProperty> WithMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string errorMessage, Func<T, TProperty, object>[] funcs)

Specifies a custom error message to use if validation fails.

public static IRuleBuilderOptions<T, TProperty> WithName<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string overridePropertyName)

Specifies a custom property name to use within the error message.

public static IRuleBuilderOptions<T, TProperty> WithPropertyName<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, string propertyName)

Overrides the name of the property associated with this rule. NOTE: This is a considered to be an advanced feature. 99% of the time that you use this, you actually meant to use WithName.

public static IRuleBuilderOptions<T, TProperty> WithState<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Func<T, object> stateProvider)

Specifies custom state that should be stored alongside the validation message when validation fails for this rule.