开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜