I am using FluentValidation 2 to validate some objects. I would like to create IValidationServiceone that I can transfer to other services so that they can perform validation. I would like to expose this as follows:
public interface IValidationEngine
{
IEnumerable<ValidationError> Validate<T>(T entity);
}
Where ValidationErroris a class that encapsulates my validation errors. Ideally, I would not expose a specific validator to one of my services (for example, OrderValidator). I would like the validation service to be able to build / find the correct validator. Does FV have something built-in to search for a validator for a specific type (and it internally caches)? Or do I need to go through the route IValidatorFactoryand then connect each validator to the IoC container?
source
share