Source for file EmailValidatorRule.class.php

Documentation is available at EmailValidatorRule.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."utilities/FieldSetValidator/rules/RegexValidatorRule.class.php");
  4.  
  5. /**
  6. * a EmailValidatorRule checks a given value to make sure it is an email address
  7. *
  8. * @package harmoni.utilities.fieldsetvalidator.rules
  9. *
  10. * @copyright Copyright &copy; 2005, Middlebury College
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  12. *
  13. * @version $Id: EmailValidatorRule.class.php,v 1.5 2007/09/04 20:25:55 adamfranco Exp $
  14. */
  15. class EmailValidatorRule
  16. extends RegexValidatorRule
  17. {
  18. /**
  19. * the constructor
  20. *
  21. * @access public
  22. * @return void
  23. ***/
  24. function EmailValidatorRule( ) {
  25. $this->_regex = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$"; // matches any string that is an email address
  26. }
  27. /**
  28. * This is a static method to return an already-created instance of a validator
  29. * rule. There are at most about a hundred unique rule objects in use durring
  30. * any given execution cycle, but rule objects are instantiated hundreds of
  31. * thousands of times.
  32. *
  33. * This method follows a modified Singleton pattern
  34. *
  35. * @return object ValidatorRule
  36. * @access public
  37. * @static
  38. * @since 3/28/05
  39. */
  40. function getRule () {
  41. // Because there is no way in PHP to get the class name of the descendent
  42. // class on which this method is called, this method must be implemented
  43. // in each descendent class.
  44.  
  45. if (!isset($GLOBALS['validator_rules']) || !is_array($GLOBALS['validator_rules']))
  46. $GLOBALS['validator_rules'] = array();
  47. $class = __CLASS__;
  48. if (!isset($GLOBALS['validator_rules'][$class]))
  49. $GLOBALS['validator_rules'][$class] = new $class;
  50. return $GLOBALS['validator_rules'][$class];
  51. }
  52. }
  53.  
  54. ?>

Documentation generated on Wed, 19 Sep 2007 10:23:00 -0400 by phpDocumentor 1.3.0RC3