2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5 * Required elements validation
9 * LICENSE: This source file is subject to version 3.01 of the PHP license
10 * that is available through the world-wide-web at the following URI:
11 * http://www.php.net/license/3_01.txt If you did not receive a copy of
12 * the PHP License and are unable to obtain it through the web, please
13 * send a note to license@php.net so we can mail you a copy immediately.
16 * @package HTML_QuickForm
17 * @author Bertrand Mansion <bmansion@mamasam.com>
18 * @copyright 2001-2011 The PHP Group
19 * @license http://www.php.net/license/3_01.txt PHP License 3.01
21 * @link http://pear.php.net/package/HTML_QuickForm
25 * Abstract base class for QuickForm validation rules
27 require_once 'HTML/QuickForm/Rule.php';
30 * Required elements validation
33 * @package HTML_QuickForm
34 * @author Bertrand Mansion <bmansion@mamasam.com>
35 * @version Release: 3.2.16
38 class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
41 * Checks if an element is empty
43 * @param string $value Value to check
44 * @param mixed $options Not used yet
46 * @return boolean true if value is not empty
48 function validate($value, $options = null)
50 if (is_array($value)) {
52 } else if ((string)$value == '') {
56 } // end func validate
59 function getValidationScript($options = null)
61 return array('', "{jsVar} == ''");
62 } // end func getValidationScript
64 } // end class HTML_QuickForm_Rule_Required