ZF-7513: Wrong error message for certain validators

Issue Type: Bug Created: 2009-08-07T01:32:03.000+0000 Last Updated: 2009-08-08T15:49:10.000+0000 Status: Resolved Fix version(s): - 1.9.1 (11/Aug/09)

Reporter: M.R. Visser (brunozen) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:


Symptoms: - unexpected error messages from certain validators.

Example: Zend_Validate_Regex has two errors: INVALID en NOT_MATCH. When the preg_match condition fails it returns the INVALID error and not the expected NOT_MATCH error. Resulting validation error message is "Invalid type given, value should be string, integer or float".

Cause of the problem: - some validators call function _error() of Zend_Validate_Abstract without parameters to indicate the validation condition has failed. - function Zend_Validate_Abstract::_error() without parameters takes the first message key from the $this->_messageTemplates array as 'the default error'. - the default error depends on the order of errors in the messageTemplates array, which is not necessarily always correct.

Affected validators with unexpected validation errors: - Zend_Validate_Regex - Zend_Validate_Hex - Zend_Validate_Float - Zend_Validate_Int - Zend_Validate_Ip

A number of other validators use the same technique but have only a single message: - Zend_Validate_GreaterThan - Zend_Validate_InArray - Zend_Validate_LessThan - Zend_Validate_Sitemap_Changefreq Which will probably cause problems when extending (and adding more messages).

Suggested solution: - always explicitly set the error key.


Posted by Thomas Weidner (thomas) on 2009-08-08T15:49:02.000+0000

Fixed with r17469

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.