Skip to content

Error messages do not distinguish between numbers and strings!Easily misleading #2706

@galaxy-s10

Description

@galaxy-s10
  const schema = Joi.object({
    isComment: [1, 2],
    status: ['1', '2'],
  });
  try {
    const res = await schema.validateAsync(
      { isComment: '1', status: 1 },
      {
        abortEarly: false,
        allowUnknown: false,
        presence: 'required',
      }
    );
    console.log('joi验证通过', res);
  } catch (error) {
    console.log('joi验证不通过', error); // "isComment" must be one of [1, 2]. "status" must be one of [1, 2]
  }

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions