Bug #57817

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

Added by Timo Dödtmann over 1 year ago. Updated over 1 year ago.

Status:Rejected Start date:2014-04-10
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:Validation
Target version:-
PHP Version: Complexity:
Has patch:No Affected Flow version:Flow 2.0.0

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.

History

#1 Updated by Gerrit Code Review over 1 year 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 1 year ago

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

#3 Updated by Bastian Waidelich over 1 year ago

  • Category set to Validation
  • Status changed from Under Review to Rejected
  • Assigned To 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 1 year ago

Hi Bastian,

good point.
Thanks for the review.

Also available in: Atom PDF