Skip to content

Number validation fails with "1E3" #2097

Closed
@kanongil

Description

@kanongil

Context

  • joi version: 15.1.1 & HEAD

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

const schema = Joi.number();

schema.validate('1e3'); // => { value: 1000 }
schema.validate(1E3); // => { value: 1000 }
schema.validate('1E3'); // fails

Which result you had ?

{
  value: 1000,
  error: [Error [ValidationError]: "value" must be a safe number] {
    _original: '1E3',
    details: [ [Object] ]
  }
}

What did you expect ?

 { value: 1000 }

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