Skip to content

Commit

Permalink
Clarify E-mail validation message for hostname.
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-kvashnin committed Apr 6, 2024
1 parent 66128b4 commit ee1f0fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Validation/EmailValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public function __invoke(string $value, Email $rule): void
throw new ValueRuleViolation($message);
}

(new HostnameValidation())($domain, new Hostname());
try {
(new HostnameValidation())($domain, new Hostname());
} catch (ValueRuleViolation $e) {
throw new ValueRuleViolation(message: 'Value must contain a valid hostname', previous: $e);
}

// DNS check (A/MX records)
if ($rule->dns && !checkdnsrr($domain) && !checkdnsrr($domain, 'A')) {
Expand Down

0 comments on commit ee1f0fc

Please sign in to comment.