custom
custom(callback, [ctx])
作用
参数
示例
const schema = racoon.number().custom((val) => {
if (val % 2 === 0) {
return true;
}
throw new Error('被检测值不为偶数');
});
schema.validate(2); // pass
schema.validate(1); // fail最后更新于
custom(callback, [ctx])
const schema = racoon.number().custom((val) => {
if (val % 2 === 0) {
return true;
}
throw new Error('被检测值不为偶数');
});
schema.validate(2); // pass
schema.validate(1); // fail最后更新于