Is there any way to overwrite Zend_Validate::is() in Magento?
I need to change the validation method for emails, so I was wondering if regular Magento overwriting rules exten开发者_如何学编程d to Zend's validaton function: Zend_Validate::is($email, 'EmailAddress')
. What's the best to overwrite it?
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);
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.
精彩评论