Make (property) Validators aware of parent class and the property they belong to
In my RFC #39788 I proposed a NotExistsValidator, which checks that no object with the same property as the annotated value exists in a specific repository.
This is needed for example when validating that an email or username doesn't yet exist during registration.
Such an validator however is not possible without providing all validators with some kind of reflection/information on their parent class and the property they belong to.
Another possible enhancement would be for Validators that depend on the value of sibling properties - i.e. a validator for "repeat e-mail/password" functionality.
For this however, the validators need to be aware of not only the parent class name, but the concrete instance of the parent class. This information however is only available at the invocation of the validate function.
Together, those additions would allow for much more flexible validators to be written, like the named above.
A possible solution for this would be to provide getters/setters for both ValidatedParentObject and ValidatedProperty, which are set before invocation of the GeneralObjectValidator property validators. Likewise, the collection/conjunction/disjunction validators would need to forward their own ValidatedParentObject/ValidatedProperty to the children validator instances.
However, for singleton validators to work reliably with those properties, they need to be unset every time after the validate() call, which makes everything look a bit ugly. I'm open for suggestions on a nicer solution for that.
Another open point is which, if any, of those methods should go into the ValidatorInterface.