StringLengthValidator accept empty value, although the "minimum" option is greater than "0"
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.
Updated by Bastian Waidelich over 7 years ago
- Category set to Validation
- Status changed from Under Review to Rejected
- Assignee set to Bastian Waidelich
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.