The signature for adding ASP.NET Client Validator factories has changed in FluentValidation 10.0. Factories now receive an IValidationRule and an IRuleComponent instead of a PropertyRule and IPropertyValidator. Additionally, because property validators are now generic, it is recommended to use the non-generic interface (e.g., IMyCustomPropertyValidator) as the lookup key.
// After migration
public class MyCustomClientsideAdaptor : ClientValidatorBase
{
public MyCustomClientsideAdaptor(IValidationRule rule, IRuleComponent component)
: base(rule, component)
{
}
public override void AddValidation(ClientModelValidationContext context)
{
// ...
}
}
services.AddMvc().AddFluentValidation(fv =>
{
fv.ConfigureClientsideValidation(clientSide =>
{
clientSide.Add(typeof(IMyCustomPropertyValidator), (context, rule, component) => new MyCustomClientsideAdaptor(rule, component));
})
})