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