respect-validation/tests/integration/rules/min.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.1 KiB
PHP

--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
run([
'Default' => [v::min(v::equals(1)), [2, 3]],
'Negative' => [v::not(v::min(v::equals(1))), [1, 2, 3]],
'With template' => [v::min(v::equals(1)), [2, 3], 'That did not go as planned'],
'With name' => [v::min(v::equals(1))->setName('Options'), [2, 3]],
]);
?>
--EXPECT--
Default
⎺⎺⎺⎺⎺⎺⎺
As the minimum from `[2, 3]`, 2 must equal 1
- As the minimum from `[2, 3]`, 2 must equal 1
[
'minEquals' => 'As the minimum from `[2, 3]`, 2 must equal 1',
]
Negative
⎺⎺⎺⎺⎺⎺⎺⎺
As the minimum from `[1, 2, 3]`, 1 must not equal 1
- As the minimum from `[1, 2, 3]`, 1 must not equal 1
[
'notMinEquals' => 'As the minimum from `[1, 2, 3]`, 1 must not equal 1',
]
With template
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
That did not go as planned
- That did not go as planned
[
'minEquals' => 'That did not go as planned',
]
With name
⎺⎺⎺⎺⎺⎺⎺⎺⎺
The minimum from Options must equal 1
- The minimum from Options must equal 1
[
'minEquals' => 'The minimum from Options must equal 1',
]