开发者

Zend Validate, Display one message per validator

开发者 https://www.devze.com 2023-01-06 11:23 出处:网络
I am validating an email address using zend_validate_email. For example, for email address aa@aa it throws several error messages including very technical describing that DNS mismatch (:S).

I am validating an email address using zend_validate_email. For example, for email address aa@aa it throws several error messages including very technical describing that DNS mismatch (:S).

I am trying to make it display only 1 message that I want it to (for example: "Please enter a valid email").

Is there any way of doing it elegantly, apart from creating a subclass and overriding the isValid method, clearing out the array of erro开发者_JAVA技巧r messages?

Thanks!


$validator = new Zend_Validate_EmailAddress();
// sets the message for all error types
$validator->setMessage('Please enter a valid email');
// sets the message for the INVALID_SEGMENT error
$validator->setMessage('Something with the part after the @ is wrong', Zend_Validate_EmailAddress::INVALID_SEGMENT);

For a full list of errors and message templates see the Zend_Validate_EmailAddress class

0

精彩评论

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