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" />
<PackageReference Include="Trellis.FluentValidation" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Trellis.FluentValidation&version=3.0.0-alpha.98&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FluentValidation Integration
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.ValidationResult → Result<T> |
Best Practices
- Use InlineValidator for simple cases, AbstractValidator for complex logic
- Validate value objects separately — First validate VOs, then aggregate invariants
- Use async only when needed — DB/API checks justify async, format checks do not
- Combine with ROP — FluentValidation for structure/format,
Ensurefor business rules
Related Packages
- Trellis.Results — Core
Result<T>type - Trellis.DomainDrivenDesign — Entity and aggregate patterns
- Trellis.Primitives — Type-safe value objects
License
MIT — see LICENSE for details.
| Product | Versions 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.
-
net10.0
- FluentValidation (>= 12.1.1)
- Trellis.Results (>= 3.0.0-alpha.98)
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 |