Skip to content

number().integer() can fail for values outside MAX_SAFE_INTEGER #1143

@kanongil

Description

@kanongil

Context

  • node version: v7.5.0
  • joi version: v10.3.1
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information:

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

const schema = Joi.number().integer();
schema.validate('90071992547409910.1');

Which result you had ?

{ error: null, value: 90071992547409900 }

What did you expect ?

Some kind of error, like:

{ error: 
   { ValidationError: "value" must be an integer
     isJoi: true,
     name: 'ValidationError',
     details: [ [Object] ],
     _object: '90071992547409910.1',
     annotate: [Function] },
  value: '90071992547409910.1' }

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions