Project Description
A small validation library for .NET that uses a fluent interface and lambda expressions for building validation rules for your business objects.

If you find FluentValidation useful, please consider making a donation.
Donate to Jeremy's hosting costs

The main source code repository for this project is on GitHub although it is also mirrored to CodePlex.

Example

using FluentValidation;

public class CustomerValidator: AbstractValidator<Customer> {
  public CustomerValidator() {
    RuleFor(customer => customer.Surname).NotEmpty();
    RuleFor(customer => customer.Forename).NotEmpty().WithMessage("Please specify a first name");
    RuleFor(customer => customer.Company).NotNull();
    RuleFor(customer => customer.Discount).NotEqual(0).When(customer => customer.HasDiscount);
    RuleFor(customer => customer.Address).Length(20, 250);
    RuleFor(customer => customer.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
  }

  private bool BeAValidPostcode(string postcode) {
    // custom postcode validating logic goes here
  }
}

Customer customer = new Customer();
CustomerValidator validator = new CustomerValidator();
ValidationResult results = validator.Validate(customer);

bool validationSucceeded = results.IsValid;
IList<ValidationFailure> failures = results.Errors;

Documentation

Build Server
TeamCity
Code Coverage
Last Successful Build

Supported By

ReSharper

VisualSVN

FluentValidation Articles
 Technical Jargon » FluentValidation News Feed 
Sunday, March 14, 2010  |  From Technical Jargon » FluentValidation
Monday, February 22, 2010  |  From Technical Jargon » FluentValidation
Sunday, February 14, 2010  |  From Technical Jargon » FluentValidation
Saturday, February 13, 2010  |  From Technical Jargon » FluentValidation
Monday, February 08, 2010  |  From Technical Jargon » FluentValidation
 Technical Jargon » FluentValidation News Feed 
Last edited Tue at 9:00 PM by JeremyS, version 28

 

Want to leave feedback?
Please use Discussions or Reviews instead.

Archived page comments (2)

Updating...
© 2006-2010 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2010.2.24.16331