ZF-2432: Zend_Validate validators do not all set messages


A number of Zend_Validate concrete validators do not currently set the $_messages array on a failed isValid() call, which means that if you call getMessages() after a failed validation, it may return an empty result. This is problematic when using a validator chain (such as Zend_Validate, or the new Zend_Form component), as the results of getMessages() becomes unpredictable.

Validators known to be missing this functionality include: * Digits * Alnum

Additionally, it would be useful to have the returned array use the error code for the key, such that getMessages() would return array( CODE => ).


Would you please provide some test data from which I can reproduce the behavior of {{getMessages()}} returning an empty array for each of the above listed classes? Thanks! :)

I haven't been able to reproduce the described problem with {{getMessages()}} not returning validation failure messages for either listed class, but I have added unit tests to cover the case for some basic input.

I am making the change that {{getMessages()}} returns an array such that:

assert($validator->getErrors() === array_keys($validator->getMessages()));

This allows us to deprecate the superfluous {{getErrors()}} method from the validation interface.

Resolving as cannot reproduce, having committed SVN r7450.