Feature #52231
openAdd new validator for equality between two values
0%
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).
Files
Updated by Clément MICHELET over 11 years ago
- File EqualValidator.php EqualValidator.php added
I add class for simple validation between values.
Updated by André Wuttig over 10 years ago
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)
Updated by Stefan Froemken over 10 years ago
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.
Updated by André Wuttig over 10 years ago
But this one (PropertiesEqualValidator) is more generic! You can reuse this validator for even every scenario.
Updated by Clément MICHELET over 10 years ago
- Target version set to 7.0
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.
Updated by André Wuttig over 10 years ago
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?
Updated by Alexander Opitz over 10 years ago
- Project changed from 534 to TYPO3 Core
- Category changed from Extbase: Validation to Extbase
Updated by Mathias Schreiber about 10 years ago
- Target version changed from 7.0 to 7.1 (Cleanup)
Updated by Benni Mack over 9 years ago
- Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Benni Mack over 9 years ago
- Target version changed from 7.5 to 8 LTS
Updated by Riccardo De Contardi almost 8 years ago
- Target version changed from 8 LTS to 9.0
Updated by André Wuttig almost 8 years ago
Here is my new PropertyCompareValidator.
Example:
@validate $domainObject Portrino\PxLib\Domain\Validator\PropertyCompareValidator(firstProperty=start, operator=lessThanOrEqual, secondProperty=end)