max
max(limit, [closed=true])
Effect
Restrict the max length of the detected string.
Arguments
limit(number) - The max length.[closed](boolean) - Whether it is a closed interval or not, the default istrue, which means a closed interval, it requires the detected string's length less than or equal tolimit. If you exactly setclosedtofalse, you'll get an opened interval, it requires the detected string's length strictly less thanlimit.
Example
const schema = racoon.string().max(3);
schema.validate('abcd'); // fail
schema.validate('abc'); // pass
schema.validate('ab'); // pass
const schema2 = racoon.string().max(3, false);
schema2.validate('abcd'); // fail
schema.validate('abc'); // fail
schema.validate('ab'); // passLast updated
Was this helpful?