Skip to content

Max safe integers #1504

@shide1989

Description

@shide1989

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

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codefeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions