mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 16:22:16 +02:00
Change conditions for Domain validation
Domains can have `--` as long as they don't start or end with `-` in its parts.
This commit is contained in:
parent
37a71de7d0
commit
c931e2504b
|
@ -29,16 +29,12 @@ class Domain extends AbstractComposite
|
|||
new Alnum('-'),
|
||||
new Not(new StartsWith('-')),
|
||||
new OneOf(
|
||||
new Not(
|
||||
new Contains('--')
|
||||
),
|
||||
new AllOf(
|
||||
new StartsWith('xn--'),
|
||||
new Callback(function ($str) {
|
||||
return substr_count($str, '--') == 1;
|
||||
})
|
||||
)
|
||||
)
|
||||
new Not(new Contains('--')),
|
||||
new Callback(function ($str) {
|
||||
return substr_count($str, '--') == 1;
|
||||
})
|
||||
),
|
||||
new Not(new EndsWith('-'))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@ class DomainTest extends \PHPUnit_Framework_TestCase
|
|||
['xn--bcher-kva.ch'],
|
||||
['mail.xn--bcher-kva.ch'],
|
||||
['example-hyphen.com'],
|
||||
['example--valid.com'],
|
||||
['std--a.com'],
|
||||
['r--w.com'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -76,10 +79,10 @@ class DomainTest extends \PHPUnit_Framework_TestCase
|
|||
[null],
|
||||
[''],
|
||||
['2222222domain.local'],
|
||||
['example--invalid.com'],
|
||||
['-example-invalid.com'],
|
||||
['example.invalid.-com'],
|
||||
['xn--bcher--kva.ch'],
|
||||
['example.invalid-.com'],
|
||||
['1.2.3.256'],
|
||||
['1.2.3.4'],
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue