ZF-7153: Add array handling to all validators and filters

Issue Type: New Feature Created: 2009-06-28T11:55:32.000+0000 Last Updated: 2010-10-26T02:39:23.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Thomas Weidner (thomas) Assignee: Thomas Weidner (thomas) Tags: - Zend_Filter

  • Zend_Validate

Related issues: - ZF-8768



The constructor of all filters and validators have to be reworked to use one single array as input.

This allows the usage of ini files without the need of keeping care of the order of the parameters. Additionally this unifies the usage for all validators and filters as it is then easily possible to extend them with new parameters without changing the API.

Example: new Zend_Validate_StringLength($min, $max);

Switched parameters makes problems when using INI or Zend_Form.

New behaviour: new Zend_Validate_StringLength(array('min' => $min, 'max' => $max));


Posted by Thomas Weidner (thomas) on 2009-09-08T13:57:54.000+0000

r18028 implements array and Zend_Config support to all validators.

Posted by Thomas Weidner (thomas) on 2009-09-11T15:02:37.000+0000

Added support also to all filters.

Posted by Christian Albrecht (alab) on 2009-09-19T05:40:41.000+0000

I looked into…, because i had the idea of implementing an ConstraintsTemplate array into Zend_Validate_Abstract, which seemed problematic because of missing this Array Argument Support.

Now i saw just another possible improvement: Wouldn't it be more economical to implement the __construct() method within Zend_Validate_Abstract, setting the values based on existance of an appropriate Setter Method in the individual Validators, and based on the StringLength example above move any Requirement Logic into the isValid() Method?

With Requirement Logic i mean this:

if (!array_key_exists('min', $options)) { $options['min'] = 0; }

That would also lead to an easy extensibility of Zend_Validate_Abstract like setting constraintTemplates through the config when instantiating any Validator and fetching them afterwards with a getConstraints() implemented in Zend_Validate_Abstract.

Please forgive if this was not the right place to put it in.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.