Skip to content

Class FluentValidationExecutor

Namespace: Momentum.ServiceDefaults.Messaging.Middlewares
Assembly: Momentum.ServiceDefaults.dll

Provides methods for executing FluentValidation validators against messages.

csharp
public static class FluentValidationExecutor

Inheritance

objectFluentValidationExecutor

Inherited Members

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

Remarks

This class is used by the Wolverine middleware to validate incoming messages before they are processed by handlers. It supports both single and multiple validator execution patterns.

Methods

ExecuteMany<T>(IEnumerable<IValidator<T>>, T)

Executes multiple FluentValidation validators against a message and aggregates all failures.

csharp
public static Task<List<ValidationFailure>> ExecuteMany<T>(IEnumerable<IValidator<T>> validators, T message)

Parameters

validators IEnumerable<IValidator<T>>

The validators to execute.

message T

The message instance to validate.

Returns

Task<List<ValidationFailure>>

A list of all validation failures from all validators, empty if all validations succeed.

Type Parameters

T

The type of message to validate.

ExecuteOne<T>(IValidator<T>, T)

Executes a single FluentValidation validator against a message.

csharp
public static Task<List<ValidationFailure>> ExecuteOne<T>(IValidator<T> validator, T message)

Parameters

validator IValidator<T>

The validator to execute.

message T

The message instance to validate.

Returns

Task<List<ValidationFailure>>

A list of validation failures, empty if validation succeeds.

Type Parameters

T

The type of message to validate.