ZF-7657: Custom Validator Messages may be broken

Issue Type: Bug Created: 2009-08-21T13:28:24.000+0000 Last Updated: 2009-09-30T18:32:11.000+0000 Status: Resolved Fix version(s): - 1.9.2 (25/Aug/09)

Reporter: David Joly (sgtcrumb) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:


Hello all,

I just finished pulling my hair out trying to figure out why my following code failed to set custom error messages.

$email = new Zend_Form_Element_Text('email'); $email->setRequired(true) ->setDecorators(array('ViewHelper',array('JQueryErrors', array('placement' => 'prepend')))) ->setFilters(array('StringTrim', 'StringToLower')) ->addValidator('EmailAddress',false,array({color:red}'messages' => array( 'emailAddressInvalid' => 'Please provide a valid email address.', 'emailAddressInvalidHostname' => 'Please provide a valid email address.'{color} )));

I searched through Zend_Validate_Abstract and some individual classes to see if any changes were made and couldn't find any (not the best way I know :)). I figured something must have been fixed for the 1.9.1 release that broke this feature. To be sure, I rolled back to version 1.8.2 and the above code does work.

My development environment is as follows: Windows XP Pro SP2 Apache 2.2 PHP 5.2.5


Posted by Thomas Weidner (thomas) on 2009-08-22T07:33:42.000+0000

"Does not work" is not enough information. What is your input, and which errorkeys and messages are returned ?

Posted by David Joly (sgtcrumb) on 2009-08-23T00:47:44.000+0000

Hi Thomas,

I examined the error keys being returned and they were the same as I have in my code snippet. The default messages were simply not being overridden with my custom messages.

Input: My typical testing input is anything that should cause a validation failure.

Error keys and message pairs: 'emailAddressInvalid' => "'%value%' is not a valid email address in the basic format local-part@hostname", 'emailAddressInvalidHostname' => "'%hostname%' is not a valid hostname for email address '%value%'", 'emailAddressInvalidMxRecord' => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'" 'emailAddressDotAtom' => "'%localPart%' not matched against dot-atom format" 'emailAddressQuotedString' => "'%localPart%' not matched against quoted-string format" 'emailAddressInvalidLocalPart' => "'%localPart%' is not a valid local part for email address '%value%'" 'emailAddressLengthExceeded' => "'%value%' exceeds the allowed length"

I didn't try testing all of these (or any other validators for that matter). I just downloaded 1.9.1 a couple days ago and was working on my first form when the bug manifested itself. After spending an hour or so trying to figure out why the default messages were not being overridden I rolled back to 1.8.2 and everything works fine.

'emailAddressInvalid' was definitely returning the default message: "'test value' is not a valid email address in the basic format local-part@hostname"

I'll reinstall 1.9.1 and see if I can repeat the issue with other validators when I find the time.

Best Regards

Posted by Thomas Weidner (thomas) on 2009-08-23T01:38:28.000+0000

I need your Input, what you got as Failure Message, how you setup your custom messages and what you expected to get returned.

Unittests and own tests show no problem so I need more informations.

"Anything that causes a failure" is also tested by our Unittests... when this would be enough information I would have seen the error :-)

Posted by David Joly (sgtcrumb) on 2009-08-23T21:10:14.000+0000

Hi Thomas,

I am pleased to announce that I found the bug. It was in my head :) Sorry for waisting your time. I am not a professional programmer ATM and I am still very green with this stuff. I guess it's better that I make my mistakes now rather than later, right?

Again, I want to apologize for jumping the gun here. Also, I want to thank you and the rest of the Zend Framework contributors for all your patience and hard work to bring people like me such a fantastic code base to work with (and for putting up with false alarms:)).

Best regards,


Posted by Thomas Weidner (thomas) on 2009-08-24T00:48:46.000+0000

It's no problem for us. That's why we are here.

Posted by Daniel Masson (dmasson) on 2009-09-30T18:32:02.000+0000

David, ... can you plz post how did you get this solved ??, .. I'm having very similar issues, ...

thank you

Have you found an issue?

See the Overview section for more details.


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

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