Is there any way to overwrite Zend_Validate::is() in Magento?

2.8k views Asked by At

I need to change the validation method for emails, so I was wondering if regular Magento overwriting rules extend to Zend's validaton function: Zend_Validate::is($email, 'EmailAddress'). What's the best to overwrite it?

2

There are 2 answers

2
Boris Guéry On BEST ANSWER

Write your own validator, and pass it to Zend_Validate::is() method.

Use Zend_Validate::addDefaultNamespaces() if you use a different namespace (ie: My_)

Zend_Validate:is($email, 'My_Validator_EmailAddress');

Alternatively, you can do:

$customValidator = new My_Validator_EmailAddress();
$isValid = $customaValidator->isValid($email);
0
Roman Snitko On

You can override this class by adding new file to local code pool: app/code/local/Zend/Validate.php But in this case you should copy all methods from the original class.