parameter
parameter copied to clipboard
当给值赋值 undefined 时,required: false 校验失败
传参 { a: undefined } 在校验 { a: { type: 'string', required: false } } 时, 会失败。
it.only('test paramsValidates', async () => {
const res = ctx.paramsValidate({
a: 'string',
b: { type: 'string', required: false },
}, {
a: 'ab',
b: undefined,
});
});
在 parameter 中,是用的 hasOwnProperty 判断是否有值:
这里会让
b = undefined
逃逸掉。不知道是不是什么考虑设计的