FluentValidation 11.7.1

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.

Showing the top 20 packages that depend on FluentValidation.

Packages Downloads
SanedBuildingBlocks
This package built for OIG-Saned
3,442
SanedBuildingBlocks
This package built for OIG-Saned
2,443
SanedBuildingBlocks
This package built for OIG-Saned
916
SanedBuildingBlocks
This package built for OIG-Saned
838
SanedBuildingBlocks
This package built for OIG-Saned
764
SanedBuildingBlocks
This package built for OIG-Saned
652
SanedBuildingBlocks
This package built for OIG-Saned
460
SanedBuildingBlocks
This package built for OIG-Saned
428
SanedBuildingBlocks
This package built for OIG-Saned
281
SanedBuildingBlocks
This package built for OIG-Saned
273
SanedBuildingBlocks
This package built for OIG-Saned
236
SanedBuildingBlocks
This package built for OIG-Saned
233
SanedBuildingBlocks
This package built for OIG-Saned
196
SanedBuildingBlocks
This package built for OIG-Saned
191
SanedBuildingBlocks
This package built for OIG-Saned
188
SanedBuildingBlocks
This package built for OIG-Saned
186
SanedBuildingBlocks
This package built for OIG-Saned
171
SanedBuildingBlocks
This package built for OIG-Saned
150
SanedBuildingBlocks
This package built for OIG-Saned
131
SanedBuildingBlocks
This package built for OIG-Saned
126

FluentValidation 11 is a major release. Please read the upgrade guide at https://docs.fluentvalidation.net/en/latest/upgrading-to-11.html Full release notes can be found at https://github.com/FluentValidation/FluentValidation/releases

.NET 5.0

  • No dependencies.

.NET 6.0

  • No dependencies.

.NET 7.0

  • No dependencies.

.NET Standard 2.0

.NET Standard 2.1

  • No dependencies.

Version Downloads Last updated
11.7.1 23 09/22/2023
11.5.1 25 10/07/2023
10.4.0 19 06/26/2023
10.3.6 20 06/19/2023
10.1.0 19 10/16/2023
8.6.1 15 02/18/2025
7.1.0 17 02/18/2025