mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 06:12:17 +02:00
Merge branch '1.1'
This commit is contained in:
commit
b10206bd28
|
@ -305,6 +305,9 @@ class ValidationException extends InvalidArgumentException implements ExceptionI
|
|||
public function setTemplate($template)
|
||||
{
|
||||
$this->customTemplate = true;
|
||||
if (isset(static::$defaultTemplates[$this->mode][$template])) {
|
||||
$template = static::$defaultTemplates[$this->mode][$template];
|
||||
}
|
||||
$this->template = $template;
|
||||
|
||||
$this->buildMessage();
|
||||
|
|
|
@ -29,16 +29,12 @@ class Domain extends AbstractComposite
|
|||
new Alnum('-'),
|
||||
new Not(new StartsWith('-')),
|
||||
new AnyOf(
|
||||
new Not(
|
||||
new Contains('--')
|
||||
),
|
||||
new AllOf(
|
||||
new StartsWith('xn--'),
|
||||
new Callback(function ($str) {
|
||||
return mb_substr_count($str, '--') == 1;
|
||||
})
|
||||
)
|
||||
)
|
||||
new Not(new Contains('--')),
|
||||
new Callback(function ($str) {
|
||||
return substr_count($str, '--') == 1;
|
||||
})
|
||||
),
|
||||
new Not(new EndsWith('-'))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
16
tests/integration/issue-739.phpt
Normal file
16
tests/integration/issue-739.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--FILE--
|
||||
<?php
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::when(v::alwaysInvalid(), v::alwaysValid())->check('foo');
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMainMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
"foo" is not valid
|
|
@ -68,6 +68,9 @@ class DomainTest extends TestCase
|
|||
['xn--bcher-kva.ch'],
|
||||
['mail.xn--bcher-kva.ch'],
|
||||
['example-hyphen.com'],
|
||||
['example--valid.com'],
|
||||
['std--a.com'],
|
||||
['r--w.com'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -77,10 +80,10 @@ class DomainTest extends 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