respect-validation/tests/integration/rules/endsWith.phpt
Henrique Moody cc20a442a1
Apply "SlevomatCodingStandard.TypeHints.DeclareStrictTypes"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:11:12 +01:00

43 lines
1,021 B
PHP

--CREDITS--
William Espindola <oi@williamespindola.com.br>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\EndsWithException;
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v;
try {
v::endsWith('foo')->check('bar');
} catch (EndsWithException $exception) {
echo $exception->getMessage().PHP_EOL;
}
try {
v::not(v::endsWith('foo'))->check(['bar', 'foo']);
} catch (EndsWithException $exception) {
echo $exception->getMessage().PHP_EOL;
}
try {
v::endsWith('foo')->assert('');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage().PHP_EOL;
}
try {
v::not(v::endsWith('foo'))->assert(['bar', 'foo']);
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage().PHP_EOL;
}
?>
--EXPECT--
"bar" must end with "foo"
`{ "bar", "foo" }` must not end with "foo"
- "" must end with "foo"
- `{ "bar", "foo" }` must not end with "foo"