After several months of increasing frustration with CodePlex’s svn integration, I have moved the source code for FluentValidation to GitHub.

Continuous builds can still be downloaded from my build server.

Documentation, discussions and the issue tracker will still remain on the CodePlex site, but if you want to play with the source code then you’ll need to head over to GitHub instead. If you have not used Git before then I recommend reading my Git Guide (the guide was written for the MvcContrib project, but all the concepts apply to FluentValidation too).

What’s coming with v1.2?

The upcoming release of FluentValidation (v1.2) will have several changes including the following:

A custom ModelMetadataProvider

The FluentValidationModelMetadataProvider will allow you to define ASP.NET MVC Metadata inside your validator classes, eg:

public CustomerValidator() {
   RuleFor(x => x.Surname)
      .NotNull() //regular validator
      .UIHint("Surname"); //MVC Metadata
 
}

The FluentValidationModelMetadataProvider will support the following metadata-related extension methods:

  • HiddenInput
  • UIHint
  • Scaffold
  • DataType
  • DisplayName
  • DisplayFormat
  • ReadOnly

A custom ModelValidatorProvider

Previous versions of FluentValidation had a custom IModelBinder implementation that allowed you to use FluentValidation to validate ASP.NET MVC action parameters. This will no longer be necessary in v1.2 as ASP.NET MVC 2′s ModelValidatorProvider infrastructure means FluentValidation can now be plugged in to MVC’s DefaultModelBinder:

public class MvcApplication : HttpApplication {
   public void Application_Start() {
      RegisterRoutes(RouteTable.Routes);
 
      ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new AttributedValidatorFactory()));
   }
}

Note that the FluentValidationModelValidatorProvider will only support server-side validation, not client-side validation. FluentValidation’s validation mechanism is not compatible with how ASP.NET MVC 2 generates clientside validation rules.

Customisable Validator Cascade Mode

The validator cascade mode will be customisable in v1.2. Currently, if you have multiple validators defined on a single property then all of those validators will be executed even if the first one fails. This can be changed by calling the Cascade method:

RuleFor(x => x.Surname)
  .Cascade().StopOnFirstFailure()
  .NotNull()
  .Length(1, 250);

In this case, the Length validator would not be run on the Surname property if the NotNull validator fails.

This will also be customisable globally by setting the static property ValidatorOptions.CascadeMode.

I hope to release a first beta of v1.2 in the next couple of weeks. The final release should coincide with the release of ASP.NET MVC 2.