ZF-8489: Zend_Validate_Callback does not propagate context

Issue Type: Bug Created: 2009-12-07T08:16:12.000+0000 Last Updated: 2009-12-08T10:06:20.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Paul Mitchell (libertus) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:


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.


Posted by Thomas Weidner (thomas) on 2009-12-07T08:34:10.000+0000

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.

Posted by Thomas Weidner (thomas) on 2009-12-07T08:35:38.000+0000

Closing as non-issue.

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

Posted by Matthew Weier O'Phinney (matthew) on 2009-12-07T08:49:04.000+0000

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.

Posted by Thomas Weidner (thomas) on 2009-12-07T10:21:23.000+0000

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

Posted by Paul Mitchell (libertus) on 2009-12-08T05:34:34.000+0000

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.

Posted by Thomas Weidner (thomas) on 2009-12-08T09:19:50.000+0000

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.

Posted by Paul Mitchell (libertus) on 2009-12-08T10:06:18.000+0000

Thank you, Thomas

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.