| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 /** 4 * \ingroup Validator 5 * 6 * This is the base class that the Rule classes implement. Classes extending this one 7 * can use the private method _setError for raising custom error codes (in addition to 8 * returning 'false' from the validate() method) 9 * 10 * Client classes can use the public method getError() to retrieve this error codes 11 * and perhaps show a more meaningful message based on its value (if any) 12 */ 13 class Validation 14 { 15 var $_error; 16 17 /** 18 * Initialize the validation scheme 19 */ 20 function Validation() 21 { 22 23 $this->_error = false; 24 } 25 26 /** 27 * Set a custom error code or message 28 * 29 * @param error The new error code 30 */ 31 function _setError($error) 32 { 33 $this->_error = $error; 34 } 35 36 /** 37 * For client classes, use this method to retrieve the custom error code which was (if any) 38 * that was set in the validate() method. 39 * 40 * It is not guaranteed that an unsuccessful result of the validate() method will set a custom 41 * error message, as that is completely up to the Validator class. Also depending on the 42 * class we might get different return values from this method. 43 * 44 * @return An extended error message 45 */ 46 function getError() 47 { 48 return $this->_error; 49 } 50 51 /** 52 * Implementation of the validation logic 53 * 54 * @param value The value that we're going to validate 55 * @return true if successful or false otherwise 56 * @see Rule::validate() 57 * @see Validator::validate() 58 */ 59 function validate($value) 60 { 61 throw(new Exception("Validation::validate: This method must be implemented by child classes.")); 62 die(); 63 } 64 } 65 66 ?>
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 |
|