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

Number validation fails on some strings with E-notation #2542

Closed
twoRoger opened this issue Jan 21, 2021 · 1 comment · Fixed by #2867
Closed

Number validation fails on some strings with E-notation #2542

twoRoger opened this issue Jan 21, 2021 · 1 comment · Fixed by #2867
Assignees
Labels
bug Bug or defect
Milestone

Comments

@twoRoger
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 14.15.4
  • module version with issue: 17.3.0
  • last module version without issue:
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

var joi = require("joi")
const schema = joi.number();
schema.validate('1.9642346977926366E-5'); // => 0.000019642346977926367
schema.validate('1.9642346977926364E-5'); // => ValidationError

https://runkit.com/tworoger/60094327f1b8ed001a128f13

What was the result you got?

{error: exports.ValidationError: "value" must be a safe number, value: 0.000019642346977926364}

What result did you expect?

{value: 0.000019642346977926364}

@trizotti
Copy link
Contributor

I'm looking at this issue.

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

Successfully merging a pull request may close this issue.

3 participants