custom
custom(callback, [ctx])
作用
参数
示例
const schema = racoon.object().custom((val) => {
if (Object.keys(val) === 1) {
return true;
}
throw new Error('被检测对象属性数量必须有且仅有一个');
});
schema.validate({ a: 1 }); // pass
schema.validate({ a: 1, b: 2 }); // fail最后更新于