# FluentValidation **Repository Path**: xrcdev/FluentValidation ## Basic Information - **Project Name**: FluentValidation - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-03 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README FluentValidation [Full Documentation](https://fluentvalidation.net) A small validation library for .NET that uses a fluent interface and lambda expressions for building validation rules. ### Get Started FluentValidation can be installed using the Nuget package manager or the `dotnet` CLI. ``` dotnet add package FluentValidation ``` For ASP.NET Core integration: ``` dotnet add package FluentValidation.AspNetCore ``` --- [![Build Status](https://dev.azure.com/jeremy0621/FluentValidation/_apis/build/status/FluentValidation.FluentValidation?branchName=master)](https://dev.azure.com/jeremy0621/FluentValidation/_build/latest?definitionId=5&branchName=master) | | | | | ------- | ----- | ----- | | `FluentValidation` | [![NuGet](https://img.shields.io/nuget/v/FluentValidation.svg)](https://nuget.org/packages/FluentValidation) | [![Nuget](https://img.shields.io/nuget/dt/FluentValidation.svg)](https://nuget.org/packages/FluentValidation) | | `FluentValidation.AspNetCore` | [![NuGet](https://img.shields.io/nuget/v/FluentValidation.AspNetCore.svg)](https://nuget.org/packages/FluentValidation.AspNetCore) | [![Nuget](https://img.shields.io/nuget/dt/FluentValidation.AspNetCore.svg)](https://nuget.org/packages/FluentValidation.AspNetCore) | `FluentValidation.Mvc5` | [![NuGet](https://img.shields.io/nuget/v/FluentValidation.Mvc5.svg)](https://nuget.org/packages/FluentValidation.Mvc5) | [![Nuget](https://img.shields.io/nuget/dt/FluentValidation.Mvc5.svg)](https://nuget.org/packages/FluentValidation.Mvc5) | `FluentValidation.WebApi` | [![NuGet](https://img.shields.io/nuget/v/FluentValidation.WebApi.svg)](https://nuget.org/packages/FluentValidation.WebApi) | [![Nuget](https://img.shields.io/nuget/dt/FluentValidation.WebApi.svg)](https://nuget.org/packages/FluentValidation.WebApi) ### Example ```csharp using FluentValidation; public class CustomerValidator: AbstractValidator { 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(); ValidationResult results = validator.Validate(customer); bool success = results.IsValid; IList failures = results.Errors; ``` ### Documentation [Documentation can be found on the project site.](https://fluentvalidation.net) ### License, Copyright etc FluentValidation has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). FluentValidation is copyright © 2008-2020 .NET Foundation, [Jeremy Skinner](https://jeremyskinner.co.uk) and other contributors and is licensed under the [Apache2 license](https://github.com/JeremySkinner/FluentValidation/blob/master/License.txt). ### .NET Foundation This project is supported by the [.NET Foundation](https://dotnetfoundation.org).