GerardSmit.FluentValidation
12.1.1
dotnet add package GerardSmit.FluentValidation --version 12.1.1
NuGet\Install-Package GerardSmit.FluentValidation -Version 12.1.1
<PackageReference Include="GerardSmit.FluentValidation" Version="12.1.1" />
<PackageVersion Include="GerardSmit.FluentValidation" Version="12.1.1" />
<PackageReference Include="GerardSmit.FluentValidation" />
paket add GerardSmit.FluentValidation --version 12.1.1
#r "nuget: GerardSmit.FluentValidation, 12.1.1"
#:package GerardSmit.FluentValidation@12.1.1
#addin nuget:?package=GerardSmit.FluentValidation&version=12.1.1
#tool nuget:?package=GerardSmit.FluentValidation&version=12.1.1
This is a fork of FluentValidation. For changes made in this fork, see https://github.com/GerardSmit/fluentvalidation
Below is the original README from the FluentValidation project, which contains more information about the library
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
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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