I think would be enough if ConstraintValidatorContext could provide a reference for the object the field belongs to. Then the BV custom implementation can decide what to do with it. For example with Spring we could use SpEL and do validation on a field that uses information from another field or fields on the bean. The current solution with class level validation works, but you lose the the actual path of the validated field that can be inside a list and should have a proper index. On Vivian Steller example if b as a list of Integers if you had 10 items and only 2 failed the validation you cannot tell which ones were with class level validation, if I’m not mistaken. |