Net4x.FluentValidation.Library
11.5.2
dotnet add package Net4x.FluentValidation.Library --version 11.5.2
NuGet\Install-Package Net4x.FluentValidation.Library -Version 11.5.2
<PackageReference Include="Net4x.FluentValidation.Library" Version="11.5.2" />
paket add Net4x.FluentValidation.Library --version 11.5.2
#r "nuget: Net4x.FluentValidation.Library, 11.5.2"
// Install Net4x.FluentValidation.Library as a Cake Addin #addin nuget:?package=Net4x.FluentValidation.Library&version=11.5.2 // Install Net4x.FluentValidation.Library as a Cake Tool #tool nuget:?package=Net4x.FluentValidation.Library&version=11.5.2
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 | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.0
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
-
.NETFramework 4.5
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
-
.NETFramework 4.6.1
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
-
.NETStandard 2.0
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
- System.Threading.Tasks.Extensions (>= 4.5.2)
-
.NETStandard 2.1
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
-
net6.0
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
-
net7.0
- Net35.Actions (>= 1.1.0)
- Net4x.AsyncBridge (>= 1.1.0)
- Net4x.BaseTypes (>= 1.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Net4x.FluentValidation.Library:
Package | Downloads |
---|---|
Net4x.FluentValidation.DependencyInjectionExtensions
Dependency injection extensions for FluentValidation |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
11.5.2 | 4,961 | 8/26/2023 |
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