FluentValidation 12.1.1 (original) (raw)
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 @JeremySkinnerfor 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 AbstractValidatorwhich 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 athttps://docs.fluentvalidation.net
Release Notes and Change Log
Release notes can be found on GitHub.
| Product | 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 (3.5K)
Showing the top 5 NuGet packages that depend on FluentValidation:
| Package | Downloads |
|---|---|
| FluentValidation.DependencyInjectionExtensions Dependency injection extensions for FluentValidation | 423.0M |
| FluentValidation.AspNetCore AspNetCore integration for FluentValidation | 284.6M |
| Reo.Core.DataModels Package Description | 27.1M |
| Ocelot Ocelot is an API gateway based on .NET stack. | 16.1M |
| FastEndpoints A light-weight REST Api framework for ASP.Net 8 and newer that implements REPR (Request-Endpoint-Response) Pattern. | 13.9M |
GitHub repositories (280)
Showing the top 20 popular GitHub repositories that depend on FluentValidation:
| Repository | Stars |
|---|---|
| ardalis/CleanArchitecture Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 10 | 18.3K |
| abpframework/abp Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation. | 14.3K |
| Sonarr/Sonarr Smart PVR for newsgroup and bittorrent users. | 14.0K |
| Radarr/Radarr Movie organizer/manager for usenet and torrent users. | 13.8K |
| kgrzybek/modular-monolith-with-ddd Full Modular Monolith application with Domain-Driven Design approach. | 13.8K |
| aspnetboilerplate/aspnetboilerplate ASP.NET Boilerplate - Web Application Framework | 12.0K |
| dotnet-architecture/eShopOnWeb Sample ASP.NET Core 8.0 reference application, now community supported: https://github.com/NimblePros/eShopOnWeb | 10.7K |
| dotnet/eShop A reference .NET application implementing an eCommerce site | 10.6K |
| MudBlazor/MudBlazor Blazor Component Library based on Material Design principles. Do more with Blazor, utilizing CSS and keeping JavaScript to a bare minimum. | 10.4K |
| nopSolutions/nopCommerce ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart. | 10.1K |
| ThreeMammals/Ocelot .NET API Gateway | 8.7K |
| NancyFx/Nancy Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono | 7.1K |
| EduardoPires/EquinoxProject Web Application ASP.NET 9 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices | 6.8K |
| Prowlarr/Prowlarr Prowlarr is an indexer manager/proxy built on the popular *arr .net/reactjs base stack to integrate with your various PVR apps, supporting management of both Torrent Trackers and Usenet Indexers. | 6.7K |
| fullstackhero/dotnet-starter-kit Production Grade Cloud-Ready .NET 10 Starter Kit (Web API + React Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included. | 6.6K |
| canton7/SyncTrayzor Windows tray utility / filesystem watcher / launcher for Syncthing | 6.2K |
| FastEndpoints/FastEndpoints A light-weight REST API development framework for ASP.NET 8 and newer. | 5.9K |
| Lidarr/Lidarr Looks and smells like Sonarr but made for music. | 5.4K |
| jasontaylordev/NorthwindTraders Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core. | 5.0K |
| microsoft/RulesEngine A fast and reliable .NET Rules Engine with extensive Dynamic expression support | 4.3K |
Include prerelease
Include vulnerable
Include deprecated
| Version | Downloads | Last Updated |
|---|---|---|
| 12.1.1 | 27,982,591 | 12/3/2025 |
| 12.1.0 | 7,288,750 | 11/3/2025 |
| 12.0.0 | 38,004,909 | 5/5/2025 |
| 12.0.0-preview1 | 387,885 | 1/2/2025 |
| 11.12.0 | 2,714,800 | 11/3/2025 |
| 11.11.0 | 84,754,969 | 11/16/2024 |
| 11.10.0 | 27,958,812 | 9/15/2024 |
| 11.9.2 | 35,200,015 | 6/10/2024 |
| 11.9.1 | 18,020,733 | 4/23/2024 |
| 11.9.0 | 41,945,936 | 12/21/2023 |
| 11.8.1 | 12,040,274 | 11/22/2023 |
| 11.8.0 | 11,973,210 | 10/19/2023 |
| 11.7.1 | 13,687,083 | 8/12/2023 |
| 11.7.0 | 167,429 | 8/11/2023 |
| 11.6.0 | 10,803,536 | 7/4/2023 |
| 11.5.2 | 22,910,357 | 4/7/2023 |
| 11.5.1 | 84,920,837 | 2/20/2023 |
| 11.5.0 | 3,961,811 | 2/13/2023 |
| 11.4.0 | 22,601,014 | 11/23/2022 |
| 11.3.0 | 4,309,974 | 11/10/2022 |