ZF-11479: Use php filter_var function for validators
Description
Zend_Validate does not use php built-in filter_var function. Here is a list of Validate filters that could be implemented : http://php.net/manual/en/…
I did an example for email : http://posterous.weedo.fr/a-simpler-email-address-…
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2011-06-14T13:57:19.000+0000
The email validator as currently written actually covers more cases than found in PHP's filter_var() functionality, and this is true of a large number of the various validators that have similar counter-parts in filter_var(). (Most ZF validators can be locale-aware, allowing for more flexible validation than filter_var() offers).
BTW, you might be interested in Zend_Validate_Callback, which allows you to specify your own callback for validations. When used in PHP 5.3, this allows you to curry arguments in and pass them to filter_var() easily:
One nice part of this validator is that you can also pass in custom error messages. :)
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2011-06-14T16:36:41.000+0000
In addition to what Matthew already said. PHP's filter_var functionality is often buggy. Try running the Zend_Validate testsuite against the filter_var() features and you'll find out that zend_Validate sticks better to the RFC's than filter_var by far.
Posted by Karim Cassam Chenaï (ka) on 2011-06-15T22:17:01.000+0000
OK, Thank you for the clarification :)