Email.php 897 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ vgk2MnPYuTQeTtjO86Y1AinaMAqnZRjrFQjGxtTUnrc=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2017 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.10 [rev.1.10.01]
  11. */
  12. /**
  13. * email address validator class
  14. */
  15. namespace Cube\Validate;
  16. class Email extends AbstractValidate
  17. {
  18. protected $_message = "'%s' does not contain a valid email address.";
  19. /**
  20. *
  21. * checks if the variable contains a valid email address
  22. *
  23. * @return bool return true if the validation is successful
  24. */
  25. public function isValid()
  26. {
  27. $value = $this->getValue();
  28. if (empty($value)) {
  29. return true;
  30. }
  31. if (!preg_match('#^\S+@\S+\.\S+$#', $value)) {
  32. return false;
  33. }
  34. return true;
  35. }
  36. }