mirror of
https://github.com/Respect/Validation.git
synced 2024-06-01 13:22:24 +02:00
52614d600d
The current documentation is hosted via GitHub pages rendered by "Couscous". Every time we need a new version of the documentation published we need to manually execute the "couscous". This commit reorganize the documentation to be published to "Read the Docs" because it will also allow us to have documentations per version of the library most importantly provider a search field for the documentation. The documentation will be then published on: https://respect-validation.readthedocs.io/ Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
926 B
926 B
Length
v::length(int $min, int $max)
v::length(int $min, null)
v::length(null, int $max)
v::length(int $min, int $max, boolean $inclusive = true)
Validates lengths. Most simple example:
v::stringType()->length(1, 5)->validate('abc'); // true
You can also validate only minimum length:
v::stringType()->length(5, null)->validate('abcdef'); // true
Only maximum length:
v::stringType()->length(null, 5)->validate('abc'); // true
The type as the first validator in a chain is a good practice, since length accepts many types:
v::arrayVal()->length(1, 5)->validate(['foo', 'bar']); // true
A third parameter may be passed to validate the passed values inclusive:
v::stringType()->length(1, 5, true)->validate('a'); // true
Message template for this validator includes {{minValue}}
and {{maxValue}}
.
See also: