respect-validation/tests/integration/rules/no.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--
Henrique Moody <henriquemoody@gmail.com>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Exceptions\NoException;
use Respect\Validation\Validator as v;
try {
v::not(v::no())->check('No');
} catch (NoException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::no()->check('Yes');
} catch (NoException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::not(v::no())->assert('No');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
try {
v::no()->assert('Yes');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
?>
--EXPECT--
"No" must not be similar to "No"
"Yes" must be similar to "No"
- "No" must not be similar to "No"
- "Yes" must be similar to "No"