NetEvolve.Pulse.FluentValidation
0.67.36
Prefix Reserved
dotnet add package NetEvolve.Pulse.FluentValidation --version 0.67.36
NuGet\Install-Package NetEvolve.Pulse.FluentValidation -Version 0.67.36
<PackageReference Include="NetEvolve.Pulse.FluentValidation" Version="0.67.36" />
<PackageVersion Include="NetEvolve.Pulse.FluentValidation" Version="0.67.36" />
<PackageReference Include="NetEvolve.Pulse.FluentValidation" />
paket add NetEvolve.Pulse.FluentValidation --version 0.67.36
#r "nuget: NetEvolve.Pulse.FluentValidation, 0.67.36"
#:package NetEvolve.Pulse.FluentValidation@0.67.36
#addin nuget:?package=NetEvolve.Pulse.FluentValidation&version=0.67.36
#tool nuget:?package=NetEvolve.Pulse.FluentValidation&version=0.67.36
NetEvolve.Pulse.FluentValidation
NetEvolve.Pulse.FluentValidation automatically validates commands and queries before they reach their handlers using FluentValidation validators registered in the DI container — centralizing validation at the pipeline boundary without duplicating logic inside individual handlers.
Features
- Automatic validation: Resolves all
IValidator<TRequest>instances and executes them before the handler runs. - Failure aggregation: Collects failures from all validators and throws a single
ValidationExceptionif any exist. - Pass-through when no validators: Requests with no registered validators flow to the handler unchanged — no errors, no configuration needed.
- Multiple validators supported: All registered validators for a given request type are executed and their failures are merged.
- Idempotent registration: Calling
AddFluentValidation()multiple times registers the interceptor only once. - Scoped lifetime: The interceptor resolves validators from the current DI scope on every invocation.
Installation
NuGet Package Manager
Install-Package NetEvolve.Pulse.FluentValidation
.NET CLI
dotnet add package NetEvolve.Pulse.FluentValidation
PackageReference
<PackageReference Include="NetEvolve.Pulse.FluentValidation" Version="x.x.x" />
Quick Start
Register the interceptor at startup:
services.AddPulse(c => c.AddFluentValidation());
Register your FluentValidation validators:
// Register individually
services.AddScoped<IValidator<CreateOrderCommand>, CreateOrderCommandValidator>();
// Or use FluentValidation's assembly scanning
services.AddValidatorsFromAssembly(typeof(CreateOrderCommand).Assembly);
Usage
Command Validation
using FluentValidation;
using NetEvolve.Pulse.Extensibility;
public record CreateOrderCommand(string ProductId, int Quantity) : ICommand<OrderResult>
{
public string? CorrelationId { get; set; }
}
public class CreateOrderCommandValidator : AbstractValidator<CreateOrderCommand>
{
public CreateOrderCommandValidator()
{
RuleFor(x => x.ProductId).NotEmpty().WithMessage("ProductId must not be empty.");
RuleFor(x => x.Quantity).GreaterThan(0).WithMessage("Quantity must be greater than zero.");
}
}
When CreateOrderCommand is dispatched with an empty ProductId or a non-positive Quantity, a ValidationException is thrown before the handler executes.
Query Validation
public record GetOrderQuery(string OrderId) : IQuery<OrderResult>
{
public string? CorrelationId { get; set; }
}
public class GetOrderQueryValidator : AbstractValidator<GetOrderQuery>
{
public GetOrderQueryValidator() =>
RuleFor(x => x.OrderId).NotEmpty().WithMessage("OrderId must not be empty.");
}
Multiple Validators
When multiple IValidator<TRequest> implementations are registered for the same request type, all are executed and their failures are aggregated into one ValidationException:
services.AddScoped<IValidator<CreateOrderCommand>, CreateOrderCommandValidator>();
services.AddScoped<IValidator<CreateOrderCommand>, CreateOrderBusinessRulesValidator>();
Behavior
| Scenario | Behavior |
|---|---|
| No validators registered | Request passes through to the handler unchanged |
| Validators registered, valid input | Request passes through to the handler |
| Validators registered, invalid input | ValidationException thrown before the handler executes |
| Multiple validators, one or more fail | All validators run; all failures are aggregated into one ValidationException |
Requirements
- .NET 8.0, .NET 9.0, or .NET 10.0
FluentValidation12.0 or laterNetEvolve.Pulse.ExtensibilityforIRequestInterceptor<,>andIMediatorBuilder
Contributing
Contributions are welcome! Please read the Contributing Guidelines before submitting a pull request.
Support
- Issues: Report bugs or request features on GitHub Issues
- Documentation: Read the full documentation at https://github.com/dailydevops/pulse
License
This project is licensed under the MIT License — see the LICENSE file for details.
Related Packages
- NetEvolve.Pulse - Core CQRS mediator
- NetEvolve.Pulse.Polly - Polly v8 resilience interceptors
- NetEvolve.Pulse.HttpCorrelation - HTTP correlation ID propagation
- NetEvolve.Pulse.Extensibility - Extensibility contracts
- NetEvolve.Pulse.EntityFramework - Entity Framework Core outbox persistence
- NetEvolve.Pulse.SqlServer - SQL Server ADO.NET outbox persistence
Made with ❤️ by the NetEvolve Team
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FluentValidation (>= 12.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- NetEvolve.Pulse.Extensibility (>= 0.67.36)
-
net8.0
- FluentValidation (>= 12.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- NetEvolve.Pulse.Extensibility (>= 0.67.36)
-
net9.0
- FluentValidation (>= 12.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- NetEvolve.Pulse.Extensibility (>= 0.67.36)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.67.36 | 154 | 5/10/2026 |