Skip to content

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

@clChenLiang

Description

@clChenLiang

传参 { 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
逃逸掉。不知道是不是什么考虑设计的

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions