Hello,
I've identified a conceptual logic bug in the current UniqueValidator (tested in v13.1.0 on TYPO3 13.4) that affects optional fields.
The Bug (Empty Value Bug):
If a field has a unique validation but is not mandatory, the validator still counts empty strings ("").
Steps to reproduce:
- Create a form with an optional field (e.g., a secondary email address).
- Add Typoscript validation: plugin.tx_powermail.settings.setup.validation.unique.secondary_email = 1
- Submit the form without filling out this field. (Works fine).
- Try to submit the form a second time without filling out this field.
Expected: The form submits successfully, as the field is optional and empty.
Actual: The form throws a validation error because it finds the previous empty string in the database.
Proposed Solution:
The UniqueValidator.php should simply skip validation if $answer->getValue() is empty:
$value = $answer->getValue(); if (empty($value)) { continue; }
Best regards,
Tobias Schäfer
Hello,
I've identified a conceptual logic bug in the current UniqueValidator (tested in v13.1.0 on TYPO3 13.4) that affects optional fields.
The Bug (Empty Value Bug):
If a field has a unique validation but is not mandatory, the validator still counts empty strings ("").
Steps to reproduce:
Expected: The form submits successfully, as the field is optional and empty.
Actual: The form throws a validation error because it finds the previous empty string in the database.
Proposed Solution:
The UniqueValidator.php should simply skip validation if $answer->getValue() is empty:
$value = $answer->getValue(); if (empty($value)) { continue; }Best regards,
Tobias Schäfer