I\'m using Fluent Validation with the Ninject.Web.Mvc.FluentValidation library to automatically wire up all of my validators (and use dependency injection to create the validato
If you don't want to auto wireup child validators you can add empty interface to child validator:
public class PersonalDataValidator : AbstractValidator, IChildValidator
And then in your factory:
public class FluentValidatorFactory : ValidatorFactoryBase
{
private readonly IKernel _kernel;
public FluentValidatorFactory(IKernel kernel)
{
_kernel = kernel;
}
public override IValidator CreateInstance(Type validatorType)
{
IValidator validator = _kernel.Resolve(validatorType) as IValidator;
////we dont want that windosr auto wires up all child validators.
var childValidator = validator as IChildValidator;
if (childValidator == null)
{
return validator;
}
return null;
}
}