1. sfValidatorCallback.class.php
  2. /** * sfValidatorCallback validates an input value if the given callback does not throw a sfValidatorError. * * @package symfony * @subpackage validator * @author Fabien Potencier * @version SVN: $Id: sfValidatorCallback.class.php 9048 2008-05-19 09:11:23Z FabianLange $ */
  3. class sfValidatorCallback extends sfValidatorBase
  4. {
  5. /**
  6. * Configures the current validator.
  7. *
  8. * Available options:
  9. *
  10. * * callback: A valid PHP callback (required)
  11. * * arguments: An array of arguments to pass to the callback
  12. *
  13. * @param array $options An array of options
  14. * @param array $messages An array of error messages
  15. *
  16. * @see sfValidatorBase
  17. */
  18. protected function configure($options = array(), $messages = array())
  19. {
  20. $this->addRequiredOption('callback');
  21. $this->addOption('arguments', array());
  22. $this->setOption('required', false);
  23. }
  24. /**
  25. * @see sfValidatorBase
  26. */
  27. protected function doClean($value)
  28. {
  29. return call_user_func($this->getOption('callback'), $this, $value, $this->getOption('arguments'));
  30. }
  31. }

Debug toolbar