Looking at the examples, it seems like the expected pattern for validating an object Foo
is to set all the validation rules in one AbstractValidator<Foo>
class.
However, I think it can be good to separate business logic of different validations to separate AbstractValidator<Foo>
classes, when the validations are more complex, especially when having to call external services for the validations.
I know I can implement different AbstractValidator<Foo>
and call them from a list/array,
but I am wondering, since this is a repeated pattern for me,
Is there any way to facilitate this?
I am looking for some class that get a list of AbstractValidator<Foo>
and aggregate the results, optionally also running them in parallel.