respect-validation/tests/integration/set_template_with_single_validator_should_use_template_as_main_message.phpt
Henrique Moody 751e08c9f0
Apply "SlevomatCodingStandard.Namespaces.UnusedUses"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:14:28 +01:00

33 lines
676 B
PHP

--CREDITS--
Henrique Moody <henriquemoody@gmail.com>
--TEST--
setTemplate() with single validator should use template as main message
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator;
$rule = Validator::callback('is_int')->setTemplate('{{name}} is not tasty');
try {
$rule->assert('something');
} catch (NestedValidationException $e) {
echo $e->getMessage();
}
echo PHP_EOL;
try {
$rule->check('something');
} catch (NestedValidationException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
"something" is not tasty
"something" is not tasty