ZF-1598: Filter and Validator Configuration - Public Properties or Accessor Methods: Please Choose One


For consistency's sake, please choose between public properties (ala Zend_Validate_Alpha) or get/set accessor methods (ala Zend_Validate_Between) for validator configuration options. Having them both just causes confusion.

As a secondary request, if you decide to go with accessor methods, please consider adding a method that would get all configuration options in a single call (kind of like a getMessageVariables() for config options). This would make things like trying to prepare Zend_Validate_* instances for export as JSON much easier.


Minor updates

I vote for public properties. Most of the validators just need simple settings, and don't need to have methods protecting access to those member variables.

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.


From what I've seen you're right. This issue still remains unresolved as of 1.5.1.

Please evaluate and categorize/assign as necessary.

I would say the process would be to make consistent accessor methods, leaving the public properties intact and marking them as @deprecated. Whether to actually remove them at some point would be decided later

Agreed, accessor methods make more sense, as * they can be used with the fluid interface * options should preferrable be set by the options array * having a setXXX is more intuitive (oop-like) than a $validator->optionstoset = $value;

As 95% of all validators are using accessor methods, and also through other components this syntax is used, the public properties will be depreciated.

The following validators/filters do not conform and have to be rewritten:

Zend_Validate_Alpha Zend_Validate_Alnum Zend_Validate_Emailaddress

Zend_Filter_Alpha Zend_Filter_Alnum Zend_Filter_StripTags

Implemented with r14560.

Postponed issue for resolution on 2.0 due to erasing the depreciated public properties. (Make them protected)

Fixed in ZF2 with GH-326