i want to override the default asp.net-mvc validation when posting a form so i tried using fluent.validation
i created a validator class (ProjectValidator)
public class ProjectValidator : AbstractValidator<Project>
{
public ProjectValidator()
{
RuleFor(h => h.Application).NotNull().WithName("Application");
RuleFor(h => h.FundingType).NotNull().WithName("Funding Type");
RuleFor(h => h.Description).NotEmpty().WithName("Description");
RuleFor(h => h.Name).NotEmpty().WithName("Project Name");
}
}
i put an attribute on my Data Transfer Object class
[Validator(typeof(ProjectValidator))]
public class ProjectViewModel
{
...
}
and i put this in application_start();
DataAnnotationsModelValidatorProvider
.AddImplicitRequiredAttributeForValueTypes = false;
ModelValidatorProviders.Providers.Add(
new FluentValidationModelValidatorProvider(new AttributedValidatorFactory()));
but when i post a form that uses this object, i get the following error:
Method not found: 'System.Collections.Generic.IEnumerable`1 FluentValidation.IValidatorDescriptor.GetValidatorsForMember(System.String)'.
any suggestions?