Feature #47191

Make (property) Validators aware of parent class and the property they belong to

Added by Alexander Berl over 2 years ago. Updated 6 months ago.

Status:Under Review Start date:2013-04-13
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:Validation
Target version:-
PHP Version: Complexity:
Has patch:No

Description

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.


Related issues

related to TYPO3.Flow - Feature #39788: RFC: Repository based NotExistsValidator New 2012-08-14

History

#1 Updated by Gerrit Code Review over 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19923

#2 Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19923

#3 Updated by Gerrit Code Review about 2 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19923

#4 Updated by Robert Lemke about 2 years ago

  • Target version set to 2.1

#5 Updated by Robert Lemke about 2 years ago

  • Target version deleted (2.1)

#6 Updated by Gerrit Code Review 6 months ago

Patch set 1 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/36883

Also available in: Atom PDF