ZF-3164: Zend_Validate messageTemplate keys are not all unique.


Several Zend_Validate sub-classes use non-unique messageTemplate keys, making it impossible to provide translations.

'invalid' Zend_Validate_Barcode_UpcA Zend_Validate_Barcode_Ean13

'invalidLength' Zend_Validate_Barcode_UpcA Zend_Validate_Barcode_Ean13

'stringEmpty' Zend_Validate_Alpha Zend_Validate_Alnum Zend_Validate_Digits

Since the messageTemplate keys are what is used to look up translation strings, these cannot all be translated properly. Implementing standard practice of prefixing these keys with a class name would help resolve the issue, but could break existing setups, ie:

barcodeUpcAInvalid barcodeEan13Invalid barcodeUpcAInvalidLength barcodeEan13InvalidLength alphaStringEmpty alnumStringEmpty digitsStringEmpty


Many others are not currently prefixed in this way, but are still unique and so do not trigger this issue at present.


If we'd like to address this, maybe we can coordinate with Thomas on it?

I assigned it to me due to Wil's last comment.

Has to be discussed with the dev-team as it would be a BC break.

I propose to make a sort of standard for keys. A working solution would be to name the keys like: - classError

For example: barcodeUpcInvalid barCodeEanInvalid stringLengthInvalid

and so on. I think you get an idea.

Assigned to Matthew after a discussion in #zftalk

Issue has been postponed until 2.0 after a discussion with the dev-team. Reason is that the fix for this issue would be a BC break.

Yeah, but i think dev-team could solve this right now, solving the BC issue just by keeping both old and new message keys and discouraging using of old message keys, and then removing them in 2.0.

This has already been discussed in past. Adding old and new messages raises unsolvable problems because it's not possible to have two messages available for the same error.

  • Which one of the messages should be thrown ? The new ones, or the old ones ?
  • Adding translation, as mentioned in ZF-3920, does not work, as both messages contain the same content/messageId.

Probably fixed with r17874 for ZF 1.10