2

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 error messages?

Thanks!

iBiryukov
  • 1,730
  • 4
  • 19
  • 30

1 Answers1

1
$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

David
  • 409
  • 3
  • 14