#52231Add new validator for equality between two values
Description
It should be usefull to add new core validators to allow equality between two values.
For example, in password or email confirmation, we need to compare two values (or property values).
We could make an EqualValidator
EqualValidator test if $value is equal to arguments ‘value’. An argument ‘strict’ could allow strict type comparison.
If setted in a domain object, $value is the domain object and ‘property’ must be setted.
My note :
For the EqualValidator, $value should be the property value to check (e.g : Password confirm property) not the domain object and to be tested on arguments property (e.g : Password).
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 3
History 15
-
Clément MICHELET commented and changed attached EqualValidator.php 09/25/13, 10:25
-
André Wuttig commented and changed attached PropertiesEqualValidator.php 09/02/14, 12:56
Here is my solution to compare two property values within a custom model validator. You should call this validator like this:
@validate $domainObject Portrino\PxLib\Domain\Validator\PropertiesEqualValidator(firstProperty=foo, secondProperty=bar)
-
Stefan Froemken commented 09/02/14, 13:27
For this case Extbase has already an implementation. If you have a …Domain\Model\User you have to create a ..Domain\Validator\UserValidator Class. With help of this class you have access to all properties.
-
André Wuttig commented 09/02/14, 14:50
But this one (PropertiesEqualValidator) is more generic! You can reuse this validator for even every scenario.
-
Clément MICHELET commented and changed target version 09/02/14, 16:04
Stefan Froemken wrote:
> For this case Extbase has already an implementation. If you have a …Domain\Model\User you have to create a ..Domain\Validator\UserValidator Class. With help of this class you have access to all properties.Yeah, I’m aware of that. I’m using a domain object validator to achieve that but I have to manage all the process of validation myself. The validation message is added for the domain object instead of the property. I have to target the property (with forProperty) when adding error results.
Using an annotation on a registration action could be more logical IMHO than a domain model object that trigger this validation every time.
I like the validator from André but It could be improved by using the PropertyMapper (or the reflection service) to access the properties. -
André Wuttig commented 09/02/14, 16:16
> Using an annotation on a registration action could be more logical IMHO than a domain model object that trigger this validation every time.
> I like the validator from André but It could be improved by using the PropertyMapper (or the reflection service) to access the properties.Yes this is a good idea to use the ReflectionService to determine some method parameters. For what do you think we need the propertyMapper?
-
Alexander Opitz changed project id category 09/25/14, 15:01
-
Mathias Schreiber changed target version 12/23/14, 19:45
-
Benni Mack changed target version 06/15/15, 17:45
-
Susanne Moog changed target version 08/05/15, 10:25
-
Benni Mack changed target version 09/24/15, 08:26
-
Riccardo De Contardi changed target version 02/23/17, 14:50
-
André Wuttig commented and changed attached PropertyCompareValidator.php 04/13/17, 15:56
Here is my new PropertyCompareValidator.
Example:
@validate $domainObject Portrino\PxLib\Domain\Validator\PropertyCompareValidator(firstProperty=start, operator=lessThanOrEqual, secondProperty=end)
-
Susanne Moog changed target version 01/28/18, 14:29
-
Georg Ringer commented and changed status
NewRejected 04/16/25, 15:53Hey,
going through older issues I just seen this one. If multiple properties need to be checked, the validation should happen in the controller, see https://docs.typo3.org/permalink/t3coreapi:extbase-domain-validator-model-complete for examples.
I add class for simple validation between values.