mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 08:42:15 +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>
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
run([
|
|
'Default' => [v::length(v::equals(3)), 'tulip'],
|
|
'Negative wrapped' => [v::length(v::not(v::equals(4))), 'rose'],
|
|
'Negative wrapper' => [v::not(v::length(v::equals(4))), 'fern'],
|
|
'With template' => [v::length(v::equals(3)), 'azalea', 'This is a template'],
|
|
'With wrapper name' => [v::length(v::equals(3))->setName('Cactus'), 'peyote'],
|
|
]);
|
|
?>
|
|
--EXPECT--
|
|
Default
|
|
⎺⎺⎺⎺⎺⎺⎺
|
|
The length of "tulip" must equal 3
|
|
- The length of "tulip" must equal 3
|
|
[
|
|
'lengthEquals' => 'The length of "tulip" must equal 3',
|
|
]
|
|
|
|
Negative wrapped
|
|
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
|
|
The length of "rose" must not equal 4
|
|
- The length of "rose" must not equal 4
|
|
[
|
|
'lengthNotEquals' => 'The length of "rose" must not equal 4',
|
|
]
|
|
|
|
Negative wrapper
|
|
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
|
|
The length of "fern" must not equal 4
|
|
- The length of "fern" must not equal 4
|
|
[
|
|
'notLengthEquals' => 'The length of "fern" must not equal 4',
|
|
]
|
|
|
|
With template
|
|
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
|
|
This is a template
|
|
- This is a template
|
|
[
|
|
'lengthEquals' => 'This is a template',
|
|
]
|
|
|
|
With wrapper name
|
|
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
|
|
The length of Cactus must equal 3
|
|
- The length of Cactus must equal 3
|
|
[
|
|
'lengthEquals' => 'The length of Cactus must equal 3',
|
|
]
|