ZF-12195: Zend_Validate_Callback does not support validation context
Description
Some validators like Identical make use of validation context passed as a second parameter to isValid() method. Apparently Callback passes options as a second parameter. Sometimes when you write a validator just for one situation you do not want to subclass Zend_Validate_Abstract but use Callback and may need access to the context for rules dependent on another fields' values.
Comments
Posted by Przemys?aw Wróbel (wrobel) on 2012-05-10T10:07:48.000+0000
Oops it seems that it does support context since options are merged with $input and $context like this: $options = $this->getOptions(); $callback = $this->getCallback(); $args = func_get_args(); $options = array_merge($args, $options);
but the entry in User Guide is incorrect http://framework.zend.com/manual/en/… The example says: function myMethod($value, $option) but it realy should be function myMethod($value, $context, $option) or better myMethod($value, $context, $option1, $option2, ...)
Posted by Frank Brückner (frosch) on 2012-05-10T10:53:55.000+0000
Please have a look on the last code example for the callback validator in the docs.