Issues

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

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:


$validator = new Zend_Validate_Callback(function($value) {
    return filter_var($value, FILTER_VALIDATE_EMAIL);
});

One nice part of this validator is that you can also pass in custom error messages. :)

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.

OK, Thank you for the clarification :)