default
default(value, [ctx])
Effect
Set the return value of validate and validateSilent, when the detected value is undefined | null.
Arguments
value(*) - The default return value ofvalidateandvalidateSilent. It is recommended but not necessarily to be a boolean. Whenvalueis a function, then set the return value ofvalueto be the default return value. The function has a parameter: the original detected value -undefinedornull.[ctx](*) - The execution context ifvalueis a function.
Example
const schema = racoon.boolean().default(false);
schema.validate(undefined); // pass, return: false
schema.validate(null); // pass, return: falseLast updated
Was this helpful?