| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include(PLOG_CLASS_PATH."class/data/validator/rules/rule.class.php"); 4 5 define( "DEFAULT_RULE_CASE_SENSITIVE", true); 6 define( "ERROR_RULE_VALUES_NOT_EQUAL", "error_rule_values_not_equal"); 7 8 /** 9 * \ingroup Validator_Rules 10 * 11 * checks whether an item is equal to another via the binary operator '=='. 12 * Use the setEqualValue() method to set the first value and call the validate() 13 * method with the second value. 14 */ 15 class EqualRule extends Rule 16 { 17 var $_equalValue; 18 19 /** 20 * The constructor does nothing. 21 */ 22 function EqualRule($equalValue) 23 { 24 $this->Rule(); 25 $this->_equalValue = $equalValue; 26 } 27 28 /** 29 * @return returns the value we're comparing 30 */ 31 function getEqualValue() 32 { 33 return $this->_equalValue; 34 } 35 36 /** 37 * Sets the value we're comparing to 38 * 39 * @param equalValue the valure we're comparing to 40 */ 41 function setEqualValue($equalValue) 42 { 43 $this->_equalValue = $equalValue; 44 } 45 46 /** 47 * Returns true if the two given values are equal. It will return ERROR_RULE_VALUES_NOT_EQUAL 48 * if they're not 49 */ 50 function validate($value) 51 { 52 if ($this->_equalValue == $value) 53 { 54 $this->_setError(false); 55 return true; 56 } 57 else 58 { 59 $this->_setError(ERROR_RULE_VALUES_NOT_EQUAL); 60 return false; 61 } 62 } 63 } 64 ?>
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 |
|