[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/validation/src/rule/ -> lmbDateRule.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/validation/src/rule/lmbSingleFieldRule.class.php');
  10  lmb_require('limb/datetime/src/lmbDate.class.php');
  11  
  12  /**
  13   * Checks that field value is a valid date
  14   * @package validation
  15   * @version $Id$
  16   */
  17  class lmbDateRule extends lmbSingleFieldRule
  18  {
  19    const TYPE_ISO = 1;
  20  
  21    protected $type;
  22  
  23    function __construct($field_name, $type = lmbDateRule :: TYPE_ISO, $custom_error = '')
  24    {
  25      parent :: __construct($field_name, $custom_error);
  26  
  27      $this->type = $type;
  28    }
  29  
  30    function check($value)
  31    {
  32      if($this->type == lmbDateRule :: TYPE_ISO)
  33      {
  34        if(!lmbDate :: validate((string)$value))
  35          $this->error('{Field} is not a valid ISO formatted date(YYYY-MM-DD HH:MM).');
  36      }
  37    }
  38  }
  39  ?>


Generated: Tue Oct 7 05:02:03 2008 Cross-referenced by PHPXref 0.7