Feature #47191

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

Added by Alexander Berl about 8 years ago. Updated over 6 years ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Validation
Target version:
-
Start date:
2013-04-13
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

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 NotExistsValidatorNew2012-08-14

Actions
#1

Updated by Gerrit Code Review about 8 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 about 8 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 8 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 8 years ago

  • Target version set to 2.1
#5

Updated by Robert Lemke about 8 years ago

  • Target version deleted (2.1)
#6

Updated by Gerrit Code Review over 6 years 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