public static void RegisterModelValidation(ModelValidatorProviderCollection providers, IContainerProvider containerProvider) { // From http://www.jeremyskinner.co.uk/2010/02/06/fluentvalidation-1-2-beta-2-and-mvc2-rc2/: // Disable the DataAnnotationsModelValidatorProvider's "greedy" required rule. // Out of the box, the DataAnnotationsModelValidatorProvider will *always* validate // non-nullable value types, irrespective of whether the property is decorated with a [Required] attribute. DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; var validatorFactory = new ConventionalValidatorFactory(containerProvider); providers.Add(new FluentValidationModelValidatorProvider(validatorFactory)); ModelMetadataProviders.Current = new ConventionalModelMetadataProvider(validatorFactory); }