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

Issue Type: Improvement Created: 2007-06-19T18:29:58.000+0000 Last Updated: 2011-08-26T17:53:26.000+0000 Status: Resolved Fix version(s): - Next Major Release ()

Reporter: Aaron Heimlich (aheimlich) Assignee: Thomas Weidner (thomas) Tags: - Zend_Filter

  • Zend_Validate

Related issues: Attachments:


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.


Posted by Darby Felton (darby) on 2007-06-21T09:55:31.000+0000

Minor updates

Posted by Bryce Lohr (gearhead) on 2008-02-14T07:43:31.000+0000

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.

Posted by Wil Sinclair (wil) on 2008-04-18T13:11:54.000+0000

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

Posted by Aaron Heimlich (aheimlich) on 2008-04-18T13:20:57.000+0000


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

Posted by Wil Sinclair (wil) on 2008-04-18T16:55:02.000+0000

Please evaluate and categorize/assign as necessary.

Posted by Andries Seutens (andries) on 2008-04-24T08:28:34.000+0000

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

Posted by Thomas Weidner (thomas) on 2009-03-31T03:58:30.000+0000

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.

Posted by Thomas Weidner (thomas) on 2009-03-31T04:07:41.000+0000

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

Posted by Thomas Weidner (thomas) on 2009-03-31T07:41:57.000+0000

Implemented with r14560.

Posted by Thomas Weidner (thomas) on 2009-03-31T07:43:12.000+0000

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

Posted by Thomas Weidner (thomas) on 2011-08-26T17:53:26.000+0000

Fixed in ZF2 with GH-326

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.