[ 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/ -> floatrule.class.php (source)

   1  <?php
   2  
   3      lt_include(PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php");
   4  
   5      define( "FLOAT_RULE_REG_EXP", "^([+-]?[0-9][0-9.]*)|0$");
   6      define( "ERROR_RULE_FLOAT_FORMAT_WRONG", "error_rule_float_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 FloatRule extends RegExpRule
  15      {
  16          /**
  17           * Initialize the rule
  18           */
  19          function FloatRule()
  20          {
  21              $this->RegExpRule(FLOAT_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_FLOAT_FORMAT_WRONG);
  38                  return false;
  39              }
  40          }
  41      }
  42  ?>


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