mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 00:32:16 +02:00
eeaea466ac
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>
49 lines
1 KiB
PHP
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',
|
|
]
|