Zend Framework

"max" option of Zend_Form StringLength validator considered as "min" option when "min" option is omitted

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Form
  • Labels:
    None

Description

When you create a form element from .ini file, and add a StringLength validator to your element with a .max option but without .min option, then .max is wrongly interpreted as .min.

Example:

user_details.elements.firstname.options.validators.strlen.validator = "StringLength"
user_details.elements.firstname.options.validators.strlen.options.max = "30"

Let's say I input "foo" as firstname
Actual result:

  • form does not validate
  • following error message is displayed: 'foo' is less than 30 characters long

Expected result:
  • form should validate
  • no error should be displayed

NOTE: this bug may impact other validators as well.
Problem comes from Zend_Form_Element::_loadValidator()
$instance = $r->newInstanceArgs((array) $validator['options']);

$validator['options'] is passed to constructor without taking into consideration options name<

Temporary workaround:

  • always specify a min length as well (set it to 0)

Issue Links

Activity

Hide
Thomas Weidner added a comment -

Already fixed with r18058 on 10.Sept

Show
Thomas Weidner added a comment - Already fixed with r18058 on 10.Sept

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: