Issue Feature Rejected

#52231Add new validator for equality between two values

Clément MICHELET 09/24/13, 18:36 updated 04/16/25, 15:53

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

  1. Clément MICHELET commented and changed attached EqualValidator.php <span data-processor="relativetime" data-value="2013-09-25T10:25:24+00:00" > 09/25/13, 10:25 </span>

    I add class for simple validation between values.

  2. André Wuttig commented and changed attached PropertiesEqualValidator.php <span data-processor="relativetime" data-value="2014-09-02T12:56:28+00:00" > 09/02/14, 12:56 </span>

    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)
  3. Stefan Froemken commented <span data-processor="relativetime" data-value="2014-09-02T13:27:19+00:00" > 09/02/14, 13:27 </span>

    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.

  4. André Wuttig commented <span data-processor="relativetime" data-value="2014-09-02T14:50:47+00:00" > 09/02/14, 14:50 </span>

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

  5. Clément MICHELET commented and changed target version <span data-processor="relativetime" data-value="2014-09-02T16:04:58+00:00" > 09/02/14, 16:04 </span>

    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.

  6. André Wuttig commented <span data-processor="relativetime" data-value="2014-09-02T16:16:28+00:00" > 09/02/14, 16:16 </span>

    > 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?

  7. André Wuttig commented and changed attached PropertyCompareValidator.php <span data-processor="relativetime" data-value="2017-04-13T15:56:55+00:00" > 04/13/17, 15:56 </span>

    Here is my new PropertyCompareValidator.

    Example:

    @validate  $domainObject Portrino\PxLib\Domain\Validator\PropertyCompareValidator(firstProperty=start, operator=lessThanOrEqual, secondProperty=end)
  8. Georg Ringer commented and changed status New Rejected <span data-processor="relativetime" data-value="2025-04-16T15:53:08+00:00" > 04/16/25, 15:53 </span>

    Hey,

    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.