[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/data/validator/rules/ -> numericrule.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php");
   4  
   5      define( "NUMERIC_RULE_REG_EXP", "^[0-9]+$");
   6      define( "ERROR_RULE_NUMERIC_FORMAT_WRONG", "error_rule_numeric_format_wrong");
   7  
   8      /**
   9       * \ingroup Validator_Rules
  10       *
  11       * Via a regular expression, validates whether the given string is a valid numeric value.
  12       */
  13      class NumericRule extends RegExpRule
  14      {
  15          /**
  16           * Initializes the rule
  17           */
  18          function NumericRule()
  19          {
  20              $this->RegExpRule(NUMERIC_RULE_REG_EXP, false);
  21          }
  22  
  23          /**
  24           * Returns true if the rule is successful or false otherwise. It will set the error
  25           * ERROR_RULE_NUMERIC_FORMAT_WRONG in case the validation is unsuccessful.
  26           *
  27           * @param value The value that should be checked
  28           * @return true if successful or false otherwise.
  29           */
  30          function validate($value)
  31          {
  32              if (parent::validate($value))
  33              {
  34                  $this->_setError(false);
  35                  return true;
  36              }
  37              else
  38              {
  39                  $this->_setError(ERROR_RULE_NUMERIC_FORMAT_WRONG);
  40                  return false;
  41              }
  42          }
  43      }
  44  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics