ZF-3657: Zend_Filter_Input does not always return all error messages from getMessages

Issue Type: Bug Created: 2008-07-16T03:41:45.000+0000 Last Updated: 2009-11-27T15:02:47.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Richard Turner (rjt_zygous) Assignee: Thomas Weidner (thomas) Tags: - Zend_Filter_Input

Related issues: - ZF-6764



Using the array of validators below, only one of the three regex error messages is ever returned from getMessages().

    $aValidators = array(
        'password_new' => array(
            array('StringLength', 8),
            new Zend_Validate_Regex('/[0-9]+/'),
            new Zend_Validate_Regex('/[A-Z]+/'),
            new Zend_Validate_Regex('/[a-z]+/'),
            'presence' => 'required',
            'allowEmpty' => false,
            'messages' => array(
                'Password must contain 8 or more characters', 
                'Password must contain at least one number',
                'Password must contain at least one capital letter',
                'Password must contain at least one lower case letter'

The 8 character limit check always works correctly. If the password 'aa' is submitted the the 'at least one capital' message is returned. If the password 'AA' is submitted then the 'at least one lower case letter' message is returned. If 'Aa' is used the the 'at least one number' message is returned. In ZF1.04 the correct behaviour is seen - 'AA' and 'aa' return two errors each and 'Aa' returns just the 'at least one number' message.


Posted by Thomas Weidner (thomas) on 2009-05-23T13:17:43.000+0000

Fixed component assignment

Posted by Thomas Weidner (thomas) on 2009-08-27T13:06:25.000+0000

The reason for using the messageKeys from the validator is that this enables us to translate them.

We have the following possibilities in my opinion: *) First validator returns messageKey, when more than one of the same validators are used then every additional validator can return a numerical key which would mean that the previous one is not overwritten.

BUT: This could mean that we are no longer be able to translate as most users use the messageKey of the validator for translation and not the message itself (which is often not possible as values are included)

*) We could change behaviour to return an array instead of a string when more than one message is returned.

BUT: This is very problematic as it would break an userland code, and makes things much more complicated in other components... I would not to this.

*) We could concate the messages and seperate them with a special sign ( "message1|message2"). This would not break BC but does not look good.

*) We could close this issue as won't fix and clearify this within the manual.

Posted by Thomas Weidner (thomas) on 2009-11-27T15:02:46.000+0000

Closing as won't fix.

Actually solution 4 is alreaddy available. A integration would eighter break the possibility of I18n (numeric keys) or add a BC problem (multidim array).

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.