I'm using a custom
With the default
Here is my initialization code:
ModelMetadataProvider
to help build a dynamic UI. One thing that it does is to set ModelMetadata.IsRequired
based on whether the property is required or not.With the default
DataAnnotationsModelValidatorProvider
in MVC 4 this enough to set up the necessary client side validation to ensure text is entered e.g.<input class="input-mini valid" data-val="true" data-val-required="The Background Color field is required." id="Styles_bodyBackground_" name="Styles[bodyBackground]" type="text" value="#ffffff">
However, with the FluentValidationModelValidatorProvider
enabled I no longer get the client side required validation.Here is my initialization code:
FluentValidationModelValidatorProvider.Configure(cfg =>
{
cfg.ValidatorFactory = new StructureMapValidatorFactory();
cfg.AddImplicitRequiredValidator = false;
}););
Most of my validation is done using attributes, I'm only using FluentValidation to perform complex validation as it works well with DI.