Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

Commented Issue: FluentValidationModelValidatorProvider incompatible with MVC4 [7097]

$
0
0
In wanting to add in collection of FluentValidationModelValidatorProvider ModelValidatorProviders with MVC4, it generated an exception indicating that the type does not correponding to the type of the collection ModelValidatorProvider.

This is a mismatch error between reference of version MVC3/MVC4, workaround I use a decorator here is the code:

public class FluentValidationModelValidatorProvider : System.Web.Mvc.ModelValidatorProvider
{
private global::FluentValidation.Mvc.FluentValidationModelValidatorProvider m_InnerValidationProvider;

public FluentValidationModelValidatorProvider(global::FluentValidation.IValidatorFactory validatorFactory = null)
{
m_InnerValidationProvider = new global::FluentValidation.Mvc.FluentValidationModelValidatorProvider(validatorFactory);
}

public override IEnumerable<ModelValidator> GetValidators(System.Web.Mvc.ModelMetadata metadata, ControllerContext context)
{
return m_InnerValidationProvider.GetValidators(metadata, context);
}
}




Comments: ok thank you that's what I'll do while waiting for your version. bon courage !

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>