Rule.php 2.1 KB

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