Skip to content

Error at integer validation #1544

@ManuSenpai

Description

@ManuSenpai

Context

  • node version: 8.6.0
  • joi version: 13.2.0
  • environment (node, browser): Chrome
  • used with (hapi, standalone, ...): Standalone

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

I'm trying to validate a possitive integer which length is between 10 and 15 characters

This is the code I am using

function validateNumber (value) {
return _.isNull(joi.validate(value, joi.string().required().min(10).max(15)).error) &&
_.isNull(joi.validate(value, joi.number().integer().min(0).required()).error);
}

Which result you had ?

I used as a value 999999999. (9 integers and a decimal point) and joi validates it as a 10 digit integer

What did you expect ?

I expected it to throw an error as it is not a digit. Given 999999999.9 as value throws an error correctly.

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codebugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions