Mercurial > hg > cmmr2012-drupal-site
diff core/lib/Drupal/Component/Utility/EmailValidator.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/lib/Drupal/Component/Utility/EmailValidator.php Thu May 09 15:34:47 2019 +0100 @@ -0,0 +1,33 @@ +<?php + +namespace Drupal\Component\Utility; + +use Egulias\EmailValidator\EmailValidator as EmailValidatorUtility; +use Egulias\EmailValidator\Validation\EmailValidation; +use Egulias\EmailValidator\Validation\RFCValidation; + +/** + * Validates email addresses. + */ +class EmailValidator extends EmailValidatorUtility implements EmailValidatorInterface { + + /** + * Validates an email address. + * + * @param string $email + * A string containing an email address. + * @param \Egulias\EmailValidator\Validation\EmailValidation|null $email_validation + * This argument is ignored. If it is supplied an error will be triggered. + * See https://www.drupal.org/node/2997196. + * + * @return bool + * TRUE if the address is valid. + */ + public function isValid($email, EmailValidation $email_validation = NULL) { + if ($email_validation) { + throw new \BadMethodCallException('Calling \Drupal\Component\Utility\EmailValidator::isValid() with the second argument is not supported. See https://www.drupal.org/node/2997196'); + } + return parent::isValid($email, (new RFCValidation())); + } + +}