enum
enum(...values)
Effect
Restrict the detected value to be one of values
.
Arguments
...values
(Array<*>) - The valid values that allow the detected value to be.
Example
const schema = racoon.any().enum('a', 1, true);
schema.validate('a'); // pass
schema.validate(1); // pass
schema.validate(true); // pass
schema.validate('b'); // fail
Last updated
Was this helpful?