ZF-8489: Zend_Validate_Callback does not propagate context

Description

According to Reference Guide ยง23.3.3, note "Validation Context" - "Zend_Form_Element::isValid() supports an additional argument, $context. Zend_Form::isValid() passes the entire array of data being processed to $context when validating a form, and Zend_Form_Element::isValid(), in turn, passes it to each validator."

The current trunk version of Zend_Validate_Callback does not propagate this optional context to the callback.

Comments

The manual section you are referring to is from Zend_Form.

Note that $context is only used and valid for Zend_Form but not for Zend_Validate.

Closing as non-issue.

Note that there is already a proposal written which should act as gateway/validator for context.

Thomas -- Please pass $context if available on to the callback so end-users do not need to build their own validators.

Yes, this may be Zend_Form specific, but there's no reason on generic validators such as this not to honor it. If the callback does not accept the parameter, it will simply be ignored.

I still don't see this being a bug of Zend_Validate_Callback.

Although I agree with you Thomas, I have to side with Matthew on this. The lack of context propagation unnecessarily limits the usefulness of the validator. For instance, I've patched my version of Zend_Validate_Callback to pass on the context and wrote the classic "do the passwords match on this form" validation as a one-line static method on the controller rather than a separate class.

I'm happy for this issue to be reclassified as an enhancement if that is more appropriate.

Fixed this bug with r19529. (In my eyes this is still a feature request and not a bug!)

Note that this change breaks BC and is therefor not backported to 1.9.

Thank you, Thomas