mirror of
https://github.com/Respect/Validation.git
synced 2024-06-04 23:02:16 +02:00
97b243daa1
Although helpful, the changes in the Min, Max, and Length rules made using those rules more verbose. This commit will simplify their use by allowing users to use them as prefixes. Because I was creating prefixes for those rules, I made other cool prefixes. Doing that is scary because it will generate more code to support, and I would have liked to avoid that. However, that's a valuable addition, and it's worth the risk. I might reconsider that in the future, but for now, that looks like a good idea. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
53 lines
2.7 KiB
PHP
53 lines
2.7 KiB
PHP
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
exceptionMessage(static fn() => v::keyValue('foo', 'equals', 'bar')->check(['bar' => 42]));
|
|
exceptionMessage(static fn() => v::keyValue('foo', 'equals', 'bar')->check(['foo' => 42]));
|
|
exceptionMessage(static fn() => v::keyValue('foo', 'json', 'bar')->check(['foo' => 42, 'bar' => 43]));
|
|
exceptionMessage(static fn() => v::keyValue('foo', 'equals', 'bar')->check(['foo' => 1, 'bar' => 2]));
|
|
exceptionMessage(static fn() => v::not(v::keyValue('foo', 'equals', 'bar'))->check(['foo' => 1, 'bar' => 1]));
|
|
exceptionFullMessage(static fn() => v::keyValue('foo', 'equals', 'bar')->assert(['bar' => 42]));
|
|
exceptionFullMessage(static fn() => v::keyValue('foo', 'equals', 'bar')->assert(['foo' => 42]));
|
|
exceptionFullMessage(static fn() => v::keyValue('foo', 'json', 'bar')->assert(['foo' => 42, 'bar' => 43]));
|
|
exceptionFullMessage(static fn() => v::keyValue('foo', 'equals', 'bar')->assert(['foo' => 1, 'bar' => 2]));
|
|
exceptionFullMessage(static fn() => v::not(v::keyValue('foo', 'equals', 'bar'))->assert(['foo' => 1, 'bar' => 1]));
|
|
// phpcs:disable Generic.Files.LineLength.TooLong
|
|
?>
|
|
--EXPECTF--
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
foo must be present
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
bar must be present
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
bar must be valid to validate foo
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
foo must equal 2
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
foo must not equal 1
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
- foo must be present
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
- bar must be present
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
- bar must be valid to validate foo
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
- foo must equal 2
|
|
|
|
Deprecated: The keyValue() rule has been deprecated and will be removed in the next major version. Use nested lazy() instead. in %s
|
|
- foo must not equal 1
|