mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Restored the original validateEmail() method. Created a new method called validateEmailDNS() that validates both the email address itself (using the ValidateEmail() method) as well as the domain name in the email address.
This commit is contained in:
parent
a49bad3ed8
commit
28ef275cde
@ -495,18 +495,26 @@ class Validator
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateEmail($field, $value, $checkDomain = false)
|
||||
protected function validateEmail($field, $value)
|
||||
{
|
||||
$emailIsValid = false;
|
||||
if (filter_var($value, \FILTER_VALIDATE_EMAIL) !== false) {
|
||||
$emailIsValid = true;
|
||||
if ($checkDomain) {
|
||||
$domain = idn_to_ascii(ltrim(stristr($value, '@'), '@'), 0, INTL_IDNA_VARIANT_UTS46) . '.';
|
||||
if (!checkdnsrr($domain, 'ANY')) {$emailIsValid = false;}
|
||||
}
|
||||
return filter_var($value, \FILTER_VALIDATE_EMAIL) !== false;
|
||||
}
|
||||
|
||||
return $emailIsValid;
|
||||
/**
|
||||
* Validate that a field is a valid e-mail address and the domain name is active
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateEmailDNS($field, $value)
|
||||
{
|
||||
if ($this->validateEmail($field, $value)) {
|
||||
$domain = ltrim(stristr($value, '@'), '@') . '.';
|
||||
return checkdnsrr($domain, 'ANY');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user