custom
custom(callback, [ctx])
Effect
Arguments
Example
const schema = racoon.object().custom((val) => {
if (Object.keys(val) === 1) {
return true;
}
throw new Error('The detected object must have only one key');
});
schema.validate({ a: 1 }); // pass
schema.validate({ a: 1, b: 2 }); // failLast updated