Skip to content

StreamValidationBehavior<TMessage, TResult> class

Namespace: Vitreous.FluentValidation.Behaviors
Assembly: Vitreous.FluentValidation.dll

Stream pipeline behavior that runs every registered IValidator<T> for a stream query before the stream is opened. When validation fails the handler is not called, and CreateStream returns Validation with the failures grouped by property name.

public sealed class StreamValidationBehavior<TMessage, TResult> : IStreamPipelineBehavior<TMessage, TResult> where TMessage : IStreamQuery<TResult>

TMessage

TResult

object ← StreamValidationBehavior<TMessage, TResult>

IStreamPipelineBehavior<TMessage, TResult>

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Queries without a validator pass straight through. Validation runs once, when the stream is created, not for each item.

StreamValidationBehavior(IEnumerable<IValidator<TMessage>>)

Section titled “ StreamValidationBehavior(IEnumerable<IValidator<TMessage>>)”
public StreamValidationBehavior(IEnumerable<IValidator<TMessage>> validators)

validators IEnumerable<IValidator<TMessage>>

Handle(TMessage, StreamQueryHandlerDelegate<TMessage, TResult>, CancellationToken)

Section titled “ Handle(TMessage, StreamQueryHandlerDelegate<TMessage, TResult>, CancellationToken)”

Executes this behavior step, calling next to continue the pipeline.

public ValueTask<Result<IAsyncEnumerable<TResult>>> Handle(TMessage message, StreamQueryHandlerDelegate<TMessage, TResult> next, CancellationToken ct = default)

message TMessage

next StreamQueryHandlerDelegate<TMessage, TResult>

ct CancellationToken

ValueTask<Result<IAsyncEnumerable<TResult>>>