custom
custom(callback, [ctx])
Effect
Arguments
Example
const schema = racoon.any().custom((val) => {
if (typeof val === 'number' || typeof val === 'string') {
return true;
}
throw new Error('The detected value must be a typeof number or string');
});
schema.validate(1); // pass
schema.validate('abc'); // pass
schema.validate(true); // failLast updated