respect-validation/tests/integration/rules/yes.phpt
Henrique Moody 003830b8e9
Standardize exception messages
Most exception messages in Validation use "must" and "must not" in their
templates, but a few rules don't.

I fixed most of them, but AlwaysValid and AlwaysInvalid remain because I
wonder if they will be better if I update them.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2023-04-01 05:54:52 +02:00

43 lines
934 B
PHP

--CREDITS--
Cameron Hall <me@chall.id.au>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Exceptions\YesException;
use Respect\Validation\Validator as v;
try {
v::not(v::yes())->check('Yes');
} catch (YesException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::yes()->check('si');
} catch (YesException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::not(v::yes())->assert('Yes');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
try {
v::yes()->assert('si');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
?>
--EXPECT--
"Yes" must not be similar to "Yes"
"si" must be similar to "Yes"
- "Yes" must not be similar to "Yes"
- "si" must be similar to "Yes"