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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetEvolve.Pulse.FluentValidation" Version="0.67.36" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetEvolve.Pulse.FluentValidation" Version="0.67.36" />
                    
Directory.Packages.props
<PackageReference Include="NetEvolve.Pulse.FluentValidation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetEvolve.Pulse.FluentValidation --version 0.67.36
                    
#r "nuget: NetEvolve.Pulse.FluentValidation, 0.67.36"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetEvolve.Pulse.FluentValidation@0.67.36
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetEvolve.Pulse.FluentValidation&version=0.67.36
                    
Install as a Cake Addin
#tool nuget:?package=NetEvolve.Pulse.FluentValidation&version=0.67.36
                    
Install as a Cake Tool

NetEvolve.Pulse.FluentValidation

NuGet Version NuGet Downloads License

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 ValidationException if 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
  • FluentValidation 12.0 or later
  • NetEvolve.Pulse.Extensibility for IRequestInterceptor<,> and IMediatorBuilder

Contributing

Contributions are welcome! Please read the Contributing Guidelines before submitting a pull request.

Support

License

This project is licensed under the MIT License — see the LICENSE file for details.


Made with ❤️ by the NetEvolve Team

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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