Trellis.FluentValidation
3.0.0-alpha.99
See the version list below for details.
dotnet add package Trellis.FluentValidation --version 3.0.0-alpha.99
NuGet\Install-Package Trellis.FluentValidation -Version 3.0.0-alpha.99
<PackageReference Include="Trellis.FluentValidation" Version="3.0.0-alpha.99" />
<PackageVersion Include="Trellis.FluentValidation" Version="3.0.0-alpha.99" />
<PackageReference Include="Trellis.FluentValidation" />
paket add Trellis.FluentValidation --version 3.0.0-alpha.99
#r "nuget: Trellis.FluentValidation, 3.0.0-alpha.99"
#:package Trellis.FluentValidation@3.0.0-alpha.99
#addin nuget:?package=Trellis.FluentValidation&version=3.0.0-alpha.99&prerelease
#tool nuget:?package=Trellis.FluentValidation&version=3.0.0-alpha.99&prerelease
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. |
-
net10.0
- FluentValidation (>= 12.1.1)
- Trellis.Results (>= 3.0.0-alpha.99)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Trellis.FluentValidation:
| Package | Downloads |
|---|---|
|
Trellis.Mediator.FluentValidation
Mediator pipeline adapter that plugs FluentValidation validators into the Trellis Mediator validation stage. Open-generic IMessageValidator<TMessage> that resolves every IValidator<TMessage> registered in DI and aggregates failures into a single Error.InvalidInput response. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.419 | 39 | 6/24/2026 |
| 3.0.0-alpha.418 | 74 | 6/23/2026 |
| 3.0.0-alpha.417 | 52 | 6/23/2026 |
| 3.0.0-alpha.397 | 73 | 6/18/2026 |
| 3.0.0-alpha.396 | 60 | 6/18/2026 |
| 3.0.0-alpha.394 | 73 | 6/18/2026 |
| 3.0.0-alpha.385 | 66 | 6/15/2026 |
| 3.0.0-alpha.382 | 63 | 6/12/2026 |
| 3.0.0-alpha.372 | 60 | 6/10/2026 |
| 3.0.0-alpha.360 | 79 | 6/7/2026 |
| 3.0.0-alpha.342 | 96 | 6/5/2026 |
| 3.0.0-alpha.337 | 66 | 6/3/2026 |
| 3.0.0-alpha.336 | 56 | 6/3/2026 |
| 3.0.0-alpha.304 | 73 | 5/29/2026 |
| 3.0.0-alpha.158 | 84 | 4/5/2026 |
| 3.0.0-alpha.157 | 71 | 4/4/2026 |
| 3.0.0-alpha.140 | 69 | 3/30/2026 |
| 3.0.0-alpha.137 | 68 | 3/27/2026 |
| 3.0.0-alpha.135 | 62 | 3/26/2026 |
| 3.0.0-alpha.99 | 62 | 3/4/2026 |