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

Max safe integers #1504

Closed
shide1989 opened this issue May 18, 2018 · 3 comments
Closed

Max safe integers #1504

shide1989 opened this issue May 18, 2018 · 3 comments
Assignees
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Milestone

Comments

@shide1989
Copy link

Context

  • node version: v8.6.0
  • joi version: 10.6.0
  • environment (node, browser): Node JS
  • any other relevant information:
const schema = Joi.object().keys({ id: Joi.number() })
let id = 10107199254749992
console.log(id > Number.MAX_SAFE_INTEGER) // logs 'true'
parseInt(110107199254749992) == 110107199254749980 // = true, because the value is too high

when using an integer value > Number.MAX_SAFE_INTEGER, Joi simply parsed the value without warning.
This resulted in values being valid, when they're not

I think there should be a verification with Number.isSafeInteger(value) before parsing a number

@Marsup
Copy link
Collaborator

Marsup commented May 18, 2018

It's already done on the integer check.

@shide1989
Copy link
Author

well it seems not to be working in our envirronment

@Marsup
Copy link
Collaborator

Marsup commented May 21, 2018

Have you called integer at least ? This won't work on floats obviously so it might still be a problem depending on your requirements but still a good remediation in the meantime.

@Marsup Marsup self-assigned this Aug 7, 2018
Marsup added a commit that referenced this issue Aug 8, 2018
@Marsup Marsup added request breaking changes Change that can breaking existing code labels Aug 8, 2018
@Marsup Marsup added this to the 14.0.0 milestone Aug 8, 2018
Marsup added a commit that referenced this issue Aug 8, 2018
Marsup added a commit that referenced this issue Aug 10, 2018
@Marsup Marsup closed this as completed in 11afe35 Oct 14, 2018
@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

3 participants