required
required([strict=false])
Effect
Restrict the detect value is not undefined | null.
If strict mode is turned on(strict=true), restrict the detected value is not undefined | null | [].
Arguments
[strict](boolean) - Whether turn on strict mode, default isfalse, means no-strict mode. You can exactly setstricttotrueto turn on strict mode.
Example
const schema1 = racoon.array();
schema1.validate(undefined); // pass, return: undefined
schema1.validate(null); // pass, return: null
schema1.validate([]); // pass, return: []
const schema2 = racoon.array().required();
schema2.validate(undefined); // fail
schema2.validate(null); // fail
schema2.validate([]); // pass
const schema3 = racoon.array().required(true);
schema3.validate(undefined); // fail
schema3.validate(null); // fail
schema3.validate([]); // failLast updated
Was this helpful?