Toarnbeike.Results.FluentValidation 1.0.0

dotnet add package Toarnbeike.Results.FluentValidation --version 1.0.0
                    
NuGet\Install-Package Toarnbeike.Results.FluentValidation -Version 1.0.0
                    
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="Toarnbeike.Results.FluentValidation" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Toarnbeike.Results.FluentValidation" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Toarnbeike.Results.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 Toarnbeike.Results.FluentValidation --version 1.0.0
                    
#r "nuget: Toarnbeike.Results.FluentValidation, 1.0.0"
                    
#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 Toarnbeike.Results.FluentValidation@1.0.0
                    
#: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=Toarnbeike.Results.FluentValidation&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Toarnbeike.Results.FluentValidation&version=1.0.0
                    
Install as a Cake Tool

NuGet

CI Code Coverage .NET 9 License: MIT

Toarnbeike.Results.FluentValidation

Integrate fluent result handling from Toarnbeike.Results with expressive validation logic from FluentValidation, providing seamless validation support for Result<T> using one or more IValidator<T> instances.


Features

  • Extension methods to validate Result<T> with one or more FluentValidation validators.
  • Support for both synchronous and asynchronous validation (Validate / ValidateAsync).
  • Automatic conversion of FluentValidation's ValidationFailure to Toarnbeike.Results.Failures.ValidationFailure.
  • Useful for pipeline-based validation or standalone use in service or domain layers.

Getting started

dotnet add package Toarnbeike.Results.FluentValidation

This package targets .NET 9+ and depends on:

  • Toarnbeike.Results
  • FluentValidation

Usage

Validate the value of a Result<TValue> if the result is successful.

var result = Result.Success(new RegisterUserCommand("John", "john@email.com"));

// Validate using one or more FluentValidation validators
var validated = result.Validate(new RegisterUserCommandValidator());

Validate asynchronously

var result = Result.Success(new RegisterUserCommand("John", "john@email.com"));

var validated = result.ValidateAsync(new RegisterUserCommandValidator());

Validate using multiple validators (coming from DI)

public class CreateUserCommandHandler(IEnumerable<IValidator<CreateUserCommand>> validators) 
{
    public async Task<Result> Handle(CreateUserCommand command)
    {
        return await Result.Success(command)
            .ValidateAsync(validators);
            // other extensions methods that handle the command.
    }
}

When to use Validate vs. ValidateAsync

Use:

  • .Validate() when your validators are fully synchronous
  • .ValidateAsync() when any of your validators use asynchronous logic, such as MustAsync, or if you are not sure.

There is currently no automatic way to detect whether an IValidator<T> from FluentValidation uses async logic; when choosing the async method the full validation is always performed, even when the IValidator<T> does not contain async logic.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Toarnbeike.Results.FluentValidation:

Package Downloads
Toarnbeike.Results.Messaging

Lightweight CQRS request/response messaging built on top of Toarnbeike.Results

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 227 8/28/2025