ZF-10690: Zend_Validate_EmailAddress: Allow setMessage to set all messages

Issue Type: Bug Created: 2010-11-16T13:56:54.000+0000 Last Updated: 2012-05-30T12:24:18.000+0000 Status: Resolved Fix version(s): - 1.12.0 (27/Aug/12)

  • Next Major Release ()

Reporter: Ross Ghahremani (rossghahremani) Assignee: Martin Hujer (mhujer) Tags: - Zend_Validate

  • FixForZF1.12

Related issues: - ZF-2224

Attachments: - ZF-10690-r24811.patch


If you use setMessage without a message key, it's supposed to set all of the message templates to the given message. So When I do

$emailValidator = new Zend_Validate_EmailAddress; $emailValidator->setMessage("Invalid Email Address");

I would expect all error messages to be 'Invalid Email Address', instead my errors look like

[emailAddressInvalidHostname] => 'iasdf' is no valid hostname for email address 'ASDF@iasdf' [hostnameInvalidHostname] => 'iasdf' does not match the expected structure for a DNS hostname [hostnameLocalNameNotAllowed] => 'iasdf' appears to be a local network name but local network names are not allowed

I read through the code, It looks like the setMessage method for Zend_Validate_EmailAddress is overloading the Zend_Validate_Abstract method The abstract method has

foreach($keys as $key) { $this->setMessage($messageString, $key); }

Zend_Validate_EmailAddress does not

When I add the foreach to the email address validator it fixes the problem


Posted by Ross Ghahremani (rossghahremani) on 2010-11-20T22:08:19.000+0000

I don't think this is a duplicate, from what i can tell, the ticked linked as the duplicate is what caused this problem, the change was made in the abstract, but not in the extended EmailAddress validator. I've already started to not use these messages, because as another person pointed out, they aren't for end user consumption, but it still should work as expected.

Posted by Thomas Weidner (thomas) on 2010-12-18T10:36:17.000+0000

Fixed with GH-83

Posted by Sylvain DIDELOT (neck) on 2012-02-12T14:25:12.000+0000

Despite marked as fixed this is still an issue in 1.11.11 .

Zend_Validate_EmailAddress::setMessage will only set the first message and ignore others if $key is null. This is inconsistent with abstract method.

Posted by Martin Hujer (mhujer) on 2012-05-17T17:17:09.000+0000

Reopening as it is still an issue in upcoming ZF 1.12 (was fixed just in ZF 2) and it should be easy to fix - just manualy merge stuff from…

Posted by Martin Hujer (mhujer) on 2012-05-19T14:30:08.000+0000

Attaching patch.

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-30T12:24:18.000+0000

Committed backported patch to 1.12 in r24848. Thanks, Martin!

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.