mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 07:45:45 +01:00
The integration tests use the same pattern to test exception messages. With my changes, we won't validate which exception we throw in those tests, but matching the message is enough. I created three functions to replace most of those tests. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
32 lines
1 KiB
PHP
32 lines
1 KiB
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--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 [
|
|
'All of the required rules must pass for {{name}}'
|
|
=> 'Todas as regras requeridas devem passar para {{name}}',
|
|
'{{name}} must be of type string'
|
|
=> '{{name}} deve ser do tipo string',
|
|
'{{name}} must have a length between {{minValue}} and {{maxValue}}'
|
|
=> '{{name}} deve possuir de {{minValue}} a {{maxValue}} caracteres',
|
|
][$message];
|
|
})
|
|
);
|
|
|
|
exceptionFullMessage(static fn() => Validator::stringType()->length(2, 15)->assert(0));
|
|
?>
|
|
--EXPECT--
|
|
- Todas as regras requeridas devem passar para 0
|
|
- 0 deve ser do tipo string
|
|
- 0 deve possuir de 2 a 15 caracteres
|