ValidationBehavior<TMessage, TResult> class
Namespace: Vitreous.FluentValidation.Behaviors
Assembly: Vitreous.FluentValidation.dll
Pipeline behavior that runs every registered IValidator<T> for a command or
query before its handler. When validation fails the handler is not called, and the dispatch
returns Validation with the failures grouped by property name.
public sealed class ValidationBehavior<TMessage, TResult> : IPipelineBehavior<TMessage, TResult>Type Parameters
Section titled “Type Parameters”TMessage
TResult
Inheritance
Section titled “Inheritance”object ← ValidationBehavior<TMessage, TResult>
Implements
Section titled “Implements”IPipelineBehavior<TMessage, TResult>
Inherited Members
Section titled “Inherited Members”object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
Section titled “Remarks”Messages without a validator pass straight through. Void commands run through this behavior
too, with TResult = Unit. Validators run one after
another, and every failure from every validator is reported.
Constructors
Section titled “Constructors”ValidationBehavior(IEnumerable<IValidator<TMessage>>)
Section titled “ ValidationBehavior(IEnumerable<IValidator<TMessage>>)”public ValidationBehavior(IEnumerable<IValidator<TMessage>> validators)Parameters
Section titled “Parameters”validators IEnumerable<IValidator<TMessage>>
Methods
Section titled “Methods”Handle(TMessage, MessageHandlerDelegate<TMessage, TResult>, CancellationToken)
Section titled “ Handle(TMessage, MessageHandlerDelegate<TMessage, TResult>, CancellationToken)”Executes this behavior step, calling next to continue the pipeline.
public ValueTask<Result<TResult>> Handle(TMessage message, MessageHandlerDelegate<TMessage, TResult> next, CancellationToken ct = default)Parameters
Section titled “Parameters”message TMessage
next MessageHandlerDelegate<TMessage, TResult>