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
<PackageReference Include="Toarnbeike.Results.FluentValidation" Version="1.0.0" />
<PackageVersion Include="Toarnbeike.Results.FluentValidation" Version="1.0.0" />
<PackageReference Include="Toarnbeike.Results.FluentValidation" />
paket add Toarnbeike.Results.FluentValidation --version 1.0.0
#r "nuget: Toarnbeike.Results.FluentValidation, 1.0.0"
#:package Toarnbeike.Results.FluentValidation@1.0.0
#addin nuget:?package=Toarnbeike.Results.FluentValidation&version=1.0.0
#tool nuget:?package=Toarnbeike.Results.FluentValidation&version=1.0.0
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
toToarnbeike.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:
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>
fromFluentValidation
uses async logic; when choosing the async method the full validation is always performed, even when theIValidator<T>
does not contain async logic.
Product | Versions 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. |
-
net9.0
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- Toarnbeike.Results (>= 1.0.0)
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 |