FluentAnnotationsValidator 2.0.0-preview1
See the version list below for details.
dotnet add package FluentAnnotationsValidator --version 2.0.0-preview1
NuGet\Install-Package FluentAnnotationsValidator -Version 2.0.0-preview1
<PackageReference Include="FluentAnnotationsValidator" Version="2.0.0-preview1" />
<PackageVersion Include="FluentAnnotationsValidator" Version="2.0.0-preview1" />
<PackageReference Include="FluentAnnotationsValidator" />
paket add FluentAnnotationsValidator --version 2.0.0-preview1
#r "nuget: FluentAnnotationsValidator, 2.0.0-preview1"
#:package FluentAnnotationsValidator@2.0.0-preview1
#addin nuget:?package=FluentAnnotationsValidator&version=2.0.0-preview1&prerelease
#tool nuget:?package=FluentAnnotationsValidator&version=2.0.0-preview1&prerelease
FluentAnnotationsValidator
A fluent, type-safe validation engine for .NET that transforms [ValidationAttribute] annotations into runtime validation logic. Designed for ergonomic configuration, conditional logic, and culture-aware localization.
🌟 What's New in v2.0.0-preview1
FluentAnnotationsValidator v2.0.0-preview1 is a fresh rewrite. All legacy APIs from v1.x have been removed.
- Multi-attribute validation per property
- DSL-based configuration via
ValidationConfigurator - Conditional rules with
.When(...),.Localized(...),.UseFallbackMessage(...) - Convention-based registration from scanned assemblies
- Pluggable
IValidationMessageResolver - Scoped culture + resource binding per type
- Legacy support removed — clean slate architecture
To use the legacy version, pin to v1.2.2.
Quickstart
Basic Setup
Using AddFluentAnnotations():
using FluentAnnotationsValidator.Extensions;
services.AddFluentAnnotations();
Advanced Setup
Using either:
AddFluentAnnotationsValidators(...):
services.AddFluentAnnotationsValidators(typeof(LoginDto))
.UseFluentAnnotations()
.For<LoginDto>()
.WithCulture(CultureInfo.GetCultureInfo("fr-FR"))
.WithValidationResource<ValidationMessages>()
.Build();
AddFluentAnnotations(...)with common behavior options configuration:
services.AddFluentAnnotations(
configureBehavior: options =>
{
// common culture and resource type for all validation attributes
options.CommonCulture = CultureInfo.GetCultureInfo("fr-FR");
options.CommonResourceType = typeof(ValidationMessages);
}
);
AddFluentAnnotations(...)with scoped and common culture and resource types:
services.AddFluentAnnotations(
builder =>
// Conditional Localization rule for German
// culture and resource type scoped to LoginDto
builder.For<LoginDto>()
.When(x => x.LangCode == 'DE')
.WithCulture(CultureInfo.GetCultureInfo("de-DE"))
.WithValidationResource<AuthenticationMessages>()
.Build(),
configureBehavior: options =>
{
// common French culture and resource type for all validation rules
options.CommonCulture = CultureInfo.GetCultureInfo("fr-FR");
options.CommonResourceType = typeof(ValidationMessages);
}
);
Installation
dotnet add package FluentAnnotationsValidator --version 2.0.0-preview1
Key Concepts
| Concept | Description |
|---|---|
ValidationBehaviorOptions |
Registry of validation rules discovered via scanning or configuration |
FluentAnnotationsBuilder |
Configuration anchor: links DI services + options |
ValidationConfigurator |
Fluent DSL to configure conditional logic, culture, and resource resolution |
IValidationMessageResolver |
Pluggable fallback resolution for localized messages |
DataAnnotationsValidator<T> |
Runtime validator that hydrates validation rules from metadata and rules registry |
Test Coverage
- ✅
[Required],[EmailAddress],[MinLength],[Range],[StringLength] - ✅
.resxand static resource support - ✅ Record constructor annotations
- ✅ Upfront rule hydration + conditional overrides
Learn More
Contribute
Help shape validation ergonomics for developers worldwide. Open to extensions, diagnostics, and new DSL patterns — bring your ideas!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- FluentValidation (>= 12.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
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 |
|---|---|---|
| 2.0.0-rc.1.0.0 | 73 | 10/4/2025 |
| 2.0.0-preview1 | 448 | 7/25/2025 |
| 2.0.0-preview.2.3 | 97 | 9/26/2025 |
| 2.0.0-preview.2.2 | 122 | 8/31/2025 |
| 1.2.2 | 605 | 7/23/2025 |
| 1.2.1 | 592 | 7/22/2025 |
| 1.2.0 | 596 | 7/22/2025 |
| 1.1.0 | 526 | 7/21/2025 |