Skip to content

[BUG] UniqueValidator fails on empty fields (blocks multiple optional submissions) #1371

Description

@tobiasschaeferptb

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:

  1. Create a form with an optional field (e.g., a secondary email address).
  2. Add Typoscript validation: plugin.tx_powermail.settings.setup.validation.unique.secondary_email = 1
  3. Submit the form without filling out this field. (Works fine).
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions