FluentValidation 12.2.0
Prefix Reserveddotnet add package FluentValidation --version 12.2.0
NuGet\Install-Package FluentValidation -Version 12.2.0
<PackageReference Include="FluentValidation" Version="12.2.0" />
<PackageVersion Include="FluentValidation" Version="12.2.0" />
<PackageReference Include="FluentValidation" />
paket add FluentValidation --version 12.2.0
#r "nuget: FluentValidation, 12.2.0"
#:package FluentValidation@12.2.0
#addin nuget:?package=FluentValidation&version=12.2.0
#tool nuget:?package=FluentValidation&version=12.2.0
FluentValidation is validation library for .NET that uses a fluent interface and lambda expressions for building strongly-typed validation rules.
Supporting the project
If you use FluentValidation in a commercial project, please sponsor the project financially. FluentValidation is developed and supported by @JeremySkinner for free in his spare time and financial sponsorship helps keep the project going. You can sponsor the project via either GitHub sponsors or OpenCollective.
Example
With FluentValidation, you can define a class that inherits from AbstractValidator
which contains the rules for a particular class. The example below shows how you could define rules
for a Customer class, and then how to execute the validator.
using FluentValidation;
public class CustomerValidator: AbstractValidator<Customer> {
public CustomerValidator() {
RuleFor(x => x.Surname).NotEmpty();
RuleFor(x => x.Forename).NotEmpty().WithMessage("Please specify a first name");
RuleFor(x => x.Discount).NotEqual(0).When(x => x.HasDiscount);
RuleFor(x => x.Address).Length(20, 250);
RuleFor(x => x.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
}
private bool BeAValidPostcode(string postcode) {
// custom postcode validating logic goes here
}
}
var customer = new Customer();
var validator = new CustomerValidator();
// Execute the validator.
ValidationResult results = validator.Validate(customer);
// Inspect any validation failures.
bool success = results.IsValid;
List<ValidationFailure> failures = results.Errors;
Full Documentation
Full documentation can be found at https://docs.fluentvalidation.net
Release Notes and Change Log
Release notes can be found on GitHub.
| 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
- No dependencies.
NuGet packages (4.3K)
Showing the top 5 NuGet packages that depend on FluentValidation:
| Package | Downloads |
|---|---|
|
FluentValidation.DependencyInjectionExtensions
Dependency injection extensions for FluentValidation |
|
|
FluentValidation.AspNetCore
AspNetCore integration for FluentValidation |
|
|
Reo.Core.DataModels
Package Description |
|
|
FastEndpoints
A light-weight REST Api framework for ASP.Net 8 and newer that implements REPR (Request-Endpoint-Response) Pattern. |
|
|
Ocelot
Ocelot is an API gateway based on ASP.NET Core stack. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.2.0 | 68,976 | 10/10/2026 |
| 12.1.1 | 69,780,731 | 12/3/2025 |
| 12.1.0 | 10,407,607 | 11/3/2025 |
| 12.0.0 | 49,245,638 | 5/5/2025 |
| 12.0.0-preview1 | 459,844 | 1/2/2025 |
| 11.12.0 | 5,761,179 | 11/3/2025 |
| 11.11.0 | 112,433,869 | 11/16/2024 |
| 11.10.0 | 32,632,909 | 9/15/2024 |
| 11.9.2 | 40,011,235 | 6/10/2024 |
| 11.9.1 | 20,581,901 | 4/23/2024 |
| 11.9.0 | 46,685,268 | 12/21/2023 |
| 11.8.1 | 13,186,731 | 11/22/2023 |
| 11.8.0 | 13,056,893 | 10/19/2023 |
| 11.7.1 | 14,514,687 | 8/12/2023 |
| 11.7.0 | 183,968 | 8/11/2023 |
| 11.6.0 | 11,530,312 | 7/4/2023 |
| 11.5.2 | 24,325,239 | 4/7/2023 |
| 11.5.1 | 95,128,935 | 2/20/2023 |
| 11.5.0 | 4,448,060 | 2/13/2023 |
| 11.4.0 | 23,903,302 | 11/23/2022 |
FluentValidation 12 is a major release. Please read the upgrade guide at https://docs.fluentvalidation.net/en/latest/upgrading-to-12.html
Full release notes can be found at https://github.com/FluentValidation/FluentValidation/releases