Project

General

Profile

Actions

Feature #52231

open

Add new validator for equality between two values

Added by Clément MICHELET almost 11 years ago. Updated over 6 years ago.

Status:
New
Priority:
Could have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
medium
Sprint Focus:

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

EqualValidator.php (1.35 KB) EqualValidator.php Clément MICHELET, 2013-09-25 10:25
PropertiesEqualValidator.php (4.73 KB) PropertiesEqualValidator.php André Wuttig, 2014-09-02 12:56
PropertyCompareValidator.php (6.31 KB) PropertyCompareValidator.php André Wuttig, 2017-04-13 15:56
Actions #1

Updated by Clément MICHELET almost 11 years ago

I add class for simple validation between values.

Actions #2

Updated by André Wuttig almost 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)

Actions #3

Updated by Stefan Froemken almost 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.

Actions #4

Updated by André Wuttig almost 10 years ago

But this one (PropertiesEqualValidator) is more generic! You can reuse this validator for even every scenario.

Actions #5

Updated by Clément MICHELET almost 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.

Actions #6

Updated by André Wuttig almost 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?

Actions #7

Updated by Alexander Opitz almost 10 years ago

  • Project changed from 534 to TYPO3 Core
  • Category changed from Extbase: Validation to Extbase
Actions #8

Updated by Mathias Schreiber over 9 years ago

  • Target version changed from 7.0 to 7.1 (Cleanup)
Actions #9

Updated by Benni Mack about 9 years ago

  • Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
Actions #10

Updated by Susanne Moog almost 9 years ago

  • Target version changed from 7.4 (Backend) to 7.5
Actions #11

Updated by Benni Mack almost 9 years ago

  • Target version changed from 7.5 to 8 LTS
Actions #12

Updated by Riccardo De Contardi over 7 years ago

  • Target version changed from 8 LTS to 9.0
Actions #13

Updated by André Wuttig over 7 years ago

Here is my new PropertyCompareValidator.

Example:


@validate  $domainObject Portrino\PxLib\Domain\Validator\PropertyCompareValidator(firstProperty=start, operator=lessThanOrEqual, secondProperty=end)

Actions #14

Updated by Susanne Moog over 6 years ago

  • Target version deleted (9.0)
Actions

Also available in: Atom PDF