Trellis.FluentValidation 3.0.0-alpha.98

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

FluentValidation Integration

NuGet Package

Seamlessly convert FluentValidation errors into Trellis ValidationError objects for Railway Oriented Programming pipelines.

Installation

dotnet add package Trellis.FluentValidation
dotnet add package FluentValidation

Quick Start

Without this extension:

var validationResult = validator.Validate(user);
if (!validationResult.IsValid)
{
    var errors = validationResult.Errors
        .Select(e => Error.Validation(e.ErrorMessage, e.PropertyName));
    return Result.Failure<User>(Error.Aggregate(errors));
}
return Result.Success(user);

With this extension:

return Validator.ValidateToResult(user);

Usage

Inline Validator

public partial class User : Aggregate<UserId>
{
    public FirstName FirstName { get; }
    public int Age { get; }

    public static Result<User> TryCreate(FirstName firstName, int age)
    {
        var user = new User(firstName, age);
        return Validator.ValidateToResult(user);
    }

    private static readonly InlineValidator<User> Validator = new()
    {
        v => v.RuleFor(x => x.FirstName).NotNull(),
        v => v.RuleFor(x => x.Age)
            .GreaterThanOrEqualTo(18)
            .WithMessage("Must be 18 or older")
    };
}

Separate Validator Class

public class UserValidator : AbstractValidator<User>
{
    public UserValidator()
    {
        RuleFor(x => x.FirstName).NotNull().WithMessage("First name is required");
        RuleFor(x => x.Age).GreaterThanOrEqualTo(18).WithMessage("Must be 18 or older");
    }
}

// Use it
private static readonly UserValidator Validator = new();
return Validator.ValidateToResult(user);

Async Validation

return await Validator.ValidateToResultAsync(user, cancellationToken: cancellationToken);

API

Method Use Case
ValidateToResult(instance) Sync validation → Result<T>
ValidateToResultAsync(instance, cancellationToken: ct) Async validation (DB/API checks) → Task<Result<T>>
validationResult.ToResult(value) Convert FluentValidation.ValidationResultResult<T>

Best Practices

  1. Use InlineValidator for simple cases, AbstractValidator for complex logic
  2. Validate value objects separately — First validate VOs, then aggregate invariants
  3. Use async only when needed — DB/API checks justify async, format checks do not
  4. Combine with ROP — FluentValidation for structure/format, Ensure for business rules

License

MIT — see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET 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
3.0.0-alpha.98 0 3/3/2026
3.0.0-alpha.95 25 3/2/2026
3.0.0-alpha.94 29 3/2/2026
3.0.0-alpha.93 31 3/1/2026
3.0.0-alpha.92 49 2/28/2026
3.0.0-alpha.83 35 2/27/2026