Rule.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Abstract base class for QuickForm validation rules
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * LICENSE: This source file is subject to version 3.01 of the PHP license
  8. * that is available through the world-wide-web at the following URI:
  9. * http://www.php.net/license/3_01.txt If you did not receive a copy of
  10. * the PHP License and are unable to obtain it through the web, please
  11. * send a note to license@php.net so we can mail you a copy immediately.
  12. *
  13. * @category HTML
  14. * @package HTML_QuickForm
  15. * @author Bertrand Mansion <bmansion@mamasam.com>
  16. * @copyright 2001-2009 The PHP Group
  17. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  18. * @version CVS: $Id: Rule.php,v 1.4 2009/04/04 21:34:02 avb Exp $
  19. * @link http://pear.php.net/package/HTML_QuickForm
  20. */
  21. /**
  22. * Abstract base class for QuickForm validation rules
  23. *
  24. * @category HTML
  25. * @package HTML_QuickForm
  26. * @author Bertrand Mansion <bmansion@mamasam.com>
  27. * @version Release: 3.2.11
  28. * @since 3.2
  29. * @abstract
  30. */
  31. class HTML_QuickForm_Rule
  32. {
  33. /**
  34. * Name of the rule to use in validate method
  35. *
  36. * This property is used in more global rules like Callback and Regex
  37. * to determine which callback and which regex is to be used for validation
  38. *
  39. * @var string
  40. * @access public
  41. */
  42. public $name;
  43. /**
  44. * Validates a value
  45. *
  46. * @access public
  47. * @abstract
  48. */
  49. public function validate($value, $options)
  50. {
  51. return true;
  52. }
  53. /**
  54. * Sets the rule name
  55. *
  56. * @param string rule name
  57. * @access public
  58. */
  59. public function setName($ruleName)
  60. {
  61. $this->name = $ruleName;
  62. }
  63. /**
  64. * Returns the javascript test (the test should return true if the value is INVALID)
  65. *
  66. * @param mixed Options for the rule
  67. * @access public
  68. * @return array first element is code to setup validation, second is the check itself
  69. * @abstract
  70. */
  71. function getValidationScript($options = null)
  72. {
  73. return array('', '');
  74. }
  75. }