Bug #57817

StringLengthValidator accept empty value, although the "minimum" option is greater than "0"

Added by Timo Dödtmann over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Priority:
Should have
Category:
Validation
Target version:
-
Start date:
2014-04-10
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

For the StringLengthValidator the property "acceptsEmptyValues" is set to "TRUE", even if the "minimum" option is greater than "0".
So, if a empty string is valitated, where the minimum option is set set to e.g. "1", the StringLengthValidator doesn't generate a error.

#1

Updated by Gerrit Code Review over 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/29375

#2

Updated by Bastian Waidelich over 7 years ago

  • Project changed from TYPO3.Fluid to TYPO3.Flow
  • Category deleted (ViewHelpers)
#3

Updated by Bastian Waidelich over 7 years ago

  • Category set to Validation
  • Status changed from Under Review to Rejected
  • Assignee set to Bastian Waidelich

Hi Timo,

thanks for reporting, but the current behavior is intended:
Imagine you want to make a property optional, but if it is set it has comply with some rules (e.g. a certain minimum length, an email address).
That's why most of the validators also accept the value to be empty (this is done in most other validation frameworks too). If you want to make a property required, just add the NotEmpty validator as well.

#4

Updated by Timo Dödtmann over 7 years ago

Hi Bastian,

good point.
Thanks for the review.

Also available in: Atom PDF