respect-validation/tests/integration/rules/iterableType.phpt
Henrique Moody eeaea466ac
Prefix IDs of wrapper rule results
Because some rules work more as a prefix, it makes sense to prefix their
result ID. That will allow for a more intuitive templating, especially
when using those rules as prefixes.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-26 01:23:29 +01:00

49 lines
1 KiB
PHP

--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
run([
'Default' => [v::iterableType(), null],
'Negative' => [v::not(v::iterableType()), [1, 2, 3]],
'With template' => [v::iterableType(), null, 'Not an iterable at all'],
'With name' => [v::iterableType()->setName('Options'), null],
]);
?>
--EXPECT--
Default
⎺⎺⎺⎺⎺⎺⎺
`null` must be of type iterable
- `null` must be of type iterable
[
'iterableType' => '`null` must be of type iterable',
]
Negative
⎺⎺⎺⎺⎺⎺⎺⎺
`[1, 2, 3]` must not of type iterable
- `[1, 2, 3]` must not of type iterable
[
'notIterableType' => '`[1, 2, 3]` must not of type iterable',
]
With template
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
Not an iterable at all
- Not an iterable at all
[
'iterableType' => 'Not an iterable at all',
]
With name
⎺⎺⎺⎺⎺⎺⎺⎺⎺
Options must be of type iterable
- Options must be of type iterable
[
'iterableType' => 'Options must be of type iterable',
]