Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当给值赋值 undefined 时,required: false 校验失败 #95

Open
clChenLiang opened this issue May 21, 2022 · 0 comments
Open

当给值赋值 undefined 时,required: false 校验失败 #95

clChenLiang opened this issue May 21, 2022 · 0 comments

Comments

@clChenLiang
Copy link

传参 { 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 判断是否有值:
image
这里会让
b = undefined
逃逸掉。不知道是不是什么考虑设计的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant