mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 16:22:16 +02:00
707dcae65f
This commit will rename the "Optional" rule to"UndefOr" while soft deprecating the old name. It should work the same as the previous one but with a different name. It will also prefix the result ID, allowing more message customization. While working on it, I realized that the prefix "undefOr" had a typo, and it was using "undefOf" instead. I fixed that, too. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
22 lines
344 B
PHP
22 lines
344 B
PHP
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
run([
|
|
'optional' => [v::optional(v::scalarVal()), []],
|
|
]);
|
|
?>
|
|
--EXPECT--
|
|
optional
|
|
⎺⎺⎺⎺⎺⎺⎺⎺
|
|
`[]` must be a scalar value
|
|
- `[]` must be a scalar value
|
|
[
|
|
'undefOrScalarVal' => '`[]` must be a scalar value',
|
|
]
|