CVS: phpweather/config pw_validator.php,1.2,1.3
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-04-12 22:07:54
|
Update of /cvsroot/phpweather/phpweather/config In directory usw-pr-cvs1:/tmp/cvs-serv17323 Modified Files: pw_validator.php Log Message: Added documentation. Index: pw_validator.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/pw_validator.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- pw_validator.php 9 Apr 2002 23:21:37 -0000 1.2 +++ pw_validator.php 12 Apr 2002 22:07:51 -0000 1.3 @@ -1,23 +1,68 @@ <?php +/** Abstract baseclass for all validators. */ class pw_validator { + /** + * The message displayed when the input is invalid. + * + * @var string + * @access private + */ var $error; + + /** + * The last value validated. + * + * @var string + * @access private + */ var $value; + /** + * Constructs a new validator. + * + * @param string $error The message displayed when the input is + * invalid. + */ function pw_validator($error) { $this->error = $error; } + /** + * Validate some input. + * + * This method should be overridden by the subclasses so that they + * can validate the input according to their type. + * + * @param string $value The new value that should be validated. + * @return boolean Returns true if the input it valid, false otherwise. + * + */ function validate($value) { $this->value = $value; return true; } + /** + * Returns the error message. + * + * The message is fed to sprintf() so that '%s' in the messages is + * replaced by the last value that was validated using this + * validator. + * + * @return string The error message. + */ function get_error() { return sprintf($this->error, $this->value); } + /** + * Returns code for the keyup event in input fields. + * + * @return string A string suitable for the keyup event on an text + * input field. + */ function get_javascript($id) { return ''; } |