mirror of
https://github.com/Respect/Validation.git
synced 2024-06-28 02:00:06 +02:00
Although helpful, the changes in the Min, Max, and Length rules made using those rules more verbose. This commit will simplify their use by allowing users to use them as prefixes. Because I was creating prefixes for those rules, I made other cool prefixes. Doing that is scary because it will generate more code to support, and I would have liked to avoid that. However, that's a valuable addition, and it's worth the risk. I might reconsider that in the future, but for now, that looks like a good idea. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
24 lines
551 B
PHP
24 lines
551 B
PHP
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Factory;
|
|
use Respect\Validation\Validator;
|
|
|
|
Factory::setDefaultInstance(
|
|
(new Factory())
|
|
->withTranslator(static function (string $message): string {
|
|
return [
|
|
'{{name}} must be of type string' => '{{name}} deve ser do tipo string',
|
|
][$message] ?? $message;
|
|
})
|
|
);
|
|
|
|
exceptionMessage(static fn() => Validator::stringType()->lengthBetween(2, 15)->check(0));
|
|
?>
|
|
--EXPECT--
|
|
0 deve ser do tipo string
|