mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 06:12:17 +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>
39 lines
1.8 KiB
PHP
39 lines
1.8 KiB
PHP
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
$array = ['foo' => true, 'bar' => 42];
|
|
|
|
exceptionMessage(static fn() => v::key('baz')->assert($array));
|
|
exceptionMessage(static fn() => v::not(v::key('foo'))->assert($array));
|
|
exceptionMessage(static fn() => v::key('foo', v::falseVal(), true)->assert($array));
|
|
exceptionMessage(static fn() => v::not(v::key('foo', v::trueVal(), true))->assert($array));
|
|
exceptionMessage(static fn() => v::key('foo', v::falseVal(), false)->assert($array));
|
|
exceptionMessage(static fn() => v::not(v::key('foo', v::trueVal(), false))->assert($array));
|
|
// phpcs:disable Generic.Files.LineLength.TooLong
|
|
?>
|
|
--EXPECTF--
|
|
|
|
Deprecated: Calling key() without a second parameter has been deprecated, and will be not be allowed in the next major version. Use keyExists() instead. %s
|
|
baz must be present
|
|
|
|
Deprecated: Calling key() without a second parameter has been deprecated, and will be not be allowed in the next major version. Use keyExists() instead. %s
|
|
foo must not be present
|
|
|
|
Deprecated: Calling key() with a third parameter has been deprecated, and will be not be allowed in the next major version. Use key() without it the third parameter. %s
|
|
foo must evaluate to `false`
|
|
|
|
Deprecated: Calling key() with a third parameter has been deprecated, and will be not be allowed in the next major version. Use key() without it the third parameter. %s
|
|
foo must not evaluate to `true`
|
|
|
|
Deprecated: Calling key() with a third parameter has been deprecated, and will be not be allowed in the next major version. Use keyOptional() instead. %s
|
|
foo must evaluate to `false`
|
|
|
|
Deprecated: Calling key() with a third parameter has been deprecated, and will be not be allowed in the next major version. Use keyOptional() instead. %s
|
|
foo must not evaluate to `true`
|