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

"00000" throws number.unsafe #2406

Closed
romeupalos opened this issue Jul 17, 2020 · 0 comments · Fixed by #2408
Closed

"00000" throws number.unsafe #2406

romeupalos opened this issue Jul 17, 2020 · 0 comments · Fixed by #2408
Labels
bug Bug or defect
Milestone

Comments

@romeupalos
Copy link
Contributor

romeupalos commented Jul 17, 2020

Support plan

  • is this issue currently blocking your project? (yes/no): No (Workaround by adding unsafe() to the schema)
  • is this issue affecting a production system? (yes/no): No

Context

  • node version: v12.18.1
  • module version with issue: 17.1.1
  • last module version without issue: N/A
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

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

const schema = Joi.number()
const result = schema.validate('00000')

This affects a system that exchange messages that may contain padded numbers with a fixed length. even though there is a regex to remove leading zeros in the normalizeDecimal function, it only accounts for non zero integers.

What was the result you got?

error type 'number.unsafe'

What result did you expect?

{ error: null, value: 0 }
romeupalos pushed a commit to romeupalos/joi that referenced this issue Jul 17, 2020
@romeupalos romeupalos changed the title "00000" throw number.unsafe "00000" throws number.unsafe Jul 17, 2020
romeupalos pushed a commit to romeupalos/joi that referenced this issue Jul 17, 2020
@hueniverse hueniverse added the bug Bug or defect label Jul 19, 2020
@hueniverse hueniverse added this to the 17.2.0 milestone Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants