required
required()
Effect
Restrict the detected value is not undefined | null
.
Arguments
None
Example
const schema1 = racoon.boolean();
schema1.validate(undefined); // pass, return: undefined
schema1.validate(null); // pass, return: null
const schema2 = racoon.boolean().required();
schema2.validate(undefined); // fail
schema2.validate(null); // fail
schema2.validate(false); // pass
Last updated
Was this helpful?