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'); // trueYou can also validate only minimum length:
v::stringType()->length(5, null)->validate('abcdef'); // trueOnly maximum length:
v::stringType()->length(null, 5)->validate('abc'); // trueThe 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']); // trueA third parameter may be passed to validate the passed values inclusive:
v::stringType()->length(1, 5, true)->validate('a'); // trueMessage template for this validator includes {{minValue}} and {{maxValue}}.
See also: