[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/validation/src/rule/ -> lmbEmailRule.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/lmbDomainRule.class.php');
  10  
  11  /**
  12   * Checks that field value is a valid Email address.
  13   * @package validation
  14   * @version $Id: lmbEmailRule.class.php 5945 2007-06-06 08:31:43Z pachanga $
  15   */
  16  class lmbEmailRule extends lmbDomainRule
  17  {
  18    function check($value)
  19    {
  20      if (is_integer(strpos($value, '@')))
  21      {
  22        list($user, $domain) = split('@', $value, 2);
  23        $this->_checkUser($user);
  24        $this->_checkDomain($domain);
  25      }
  26      else
  27        $this->error('{Field} must contain a @ character.');
  28    }
  29  
  30    protected function _checkUser($value)
  31    {
  32      if (!preg_match('/^[a-z0-9]+([_.-][a-z0-9]+)*$/i', $value))
  33          $this->error('Invalid user in {Field}.');
  34    }
  35  
  36    protected function _checkDomain($value)
  37    {
  38      parent :: check($value);
  39    }
  40  }
  41  ?>


Generated: Tue Dec 2 03:54:09 2008 Cross-referenced by PHPXref 0.7