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