respect-validation/tests/integration/transformers/deprecated_max.phpt
Henrique Moody 97b243daa1
Allow building rules using prefixes
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>
2024-03-24 16:58:24 +01:00

29 lines
1.2 KiB
PHP

--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
exceptionMessage(static fn() => v::max(10)->check(11));
exceptionMessage(static fn() => v::not(v::max(10))->check(5));
exceptionFullMessage(static fn() => v::max('today')->assert('tomorrow'));
exceptionFullMessage(static fn() => v::not(v::max('b'))->assert('a'));
// phpcs:disable Generic.Files.LineLength.TooLong
?>
--EXPECTF--
Deprecated: Calling max() with a scalar value has been deprecated, and will be not allows in the next major version. Use lessThanOrEqual() instead. in %s
11 must be less than or equal to 10
Deprecated: Calling max() with a scalar value has been deprecated, and will be not allows in the next major version. Use lessThanOrEqual() instead. in %s
5 must not be less than or equal to 10
Deprecated: Calling max() with a scalar value has been deprecated, and will be not allows in the next major version. Use lessThanOrEqual() instead. in %s
- "tomorrow" must be less than or equal to "today"
Deprecated: Calling max() with a scalar value has been deprecated, and will be not allows in the next major version. Use lessThanOrEqual() instead. in %s
- "a" must not be less than or equal to "b"