Skip to content

Commit 66128b4

Browse files
Update E-mail validation so that it uses hostname validation.
1 parent 190fbb0 commit 66128b4

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/Validation/EmailValidation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Norvica\Validation\Rule\Email;
88
use Norvica\Validation\Exception\ValueRuleViolation;
9+
use Norvica\Validation\Rule\Hostname;
910

1011
final class EmailValidation
1112
{
@@ -23,6 +24,8 @@ public function __invoke(string $value, Email $rule): void
2324
throw new ValueRuleViolation($message);
2425
}
2526

27+
(new HostnameValidation())($domain, new Hostname());
28+
2629
// DNS check (A/MX records)
2730
if ($rule->dns && !checkdnsrr($domain) && !checkdnsrr($domain, 'A')) {
2831
throw new ValueRuleViolation($message);

tests/Single/EmailTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function testValidDns(string $value): void
4141

4242
public static function invalid(): Generator
4343
{
44+
yield 'invalid domain' => ['a@b.c'];
4445
yield 'only local part' => ['john.doe'];
4546
yield 'no domain part' => ['john.doe@'];
4647
yield 'no local part' => ['@example.com'];

0 commit comments

Comments
 (0)