custom
custom(callback, [ctx])
作用
参数
示例
const schema = racoon.any().custom((val) => {
if (typeof val === 'number' || typeof val === 'string') {
return true;
}
throw new Error('被检测值类型必须为number或者string');
});
schema.validate(1); // pass
schema.validate('abc'); // pass
schema.validate(true); // fail最后更新于