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

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

Closed
galaxy-s10 opened this issue Jan 24, 2022 · 1 comment
Labels
support Questions, discussions, and general support

Comments

@galaxy-s10
Copy link

galaxy-s10 commented Jan 24, 2022

@hueniverse ,hi guy,I see that this issue has been fixed in 17.5.0, ​I tried. It seems that it hasn't been repaired yet. What I expect is the following results:

  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) {
    // now
    console.log('joi验证不通过', error); // "isComment" must be one of [1, 2]. "status" must be one of [1, 2]
    // expect
    console.log('joi验证不通过', error); // "isComment" must be one of [1, 2]. "status" must be one of ['1', '2']

  }
@hueniverse
Copy link
Contributor

Answered elsewhere.

@hueniverse hueniverse added the support Questions, discussions, and general support label Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants