[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include(PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php"); 4 5 define( "INT_RULE_REG_EXP", "^([+-]?[1-9][0-9]*)|0$"); 6 define( "ERROR_RULE_INT_FORMAT_WRONG", "error_rule_int_format_wrong"); 7 8 /** 9 * \ingroup Validator_Rules 10 * 11 * Checks if the given value is an integer, not only in type but also in format. 12 * It will return ERROR_RULE_INT_FORMAT_WRONG if the format is not correct 13 */ 14 class IntRule extends RegExpRule 15 { 16 /** 17 * Initialize the rule 18 */ 19 function IntRule() 20 { 21 $this->RegExpRule(INT_RULE_REG_EXP, false); 22 } 23 24 /** 25 * Returns true if the given value is an integer, or false otherwise. In case of error 26 * it will also set the error code to ERROR_RULE_INT_FORMAT_WRONG 27 */ 28 function validate($value) 29 { 30 if (parent::validate($value)) 31 { 32 $this->_setError(false); 33 return true; 34 } 35 else 36 { 37 $this->_setError(ERROR_RULE_INT_FORMAT_WRONG); 38 return false; 39 } 40 } 41 } 42 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |