respect-validation/tests/integration/set_template_with_single_validator_should_use_template_as_main_message.phpt

33 lines
676 B
Plaintext
Raw Normal View History

--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;
2015-10-18 03:44:47 +02:00
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