Joi: number.positive() doesn't include 0

Created on 20 Nov 2015  路  4Comments  路  Source: sideway/joi

Hi,

I was validating a schema with a 0 and got "field" must be a positive number. I looked into the code and so that it's a strict comparison, for .negative() as well.
If I remember my math classes right, 0 is both negative and positive, not the other way around :bowtie:

If it's ok for you, I'll make a (small) PR to fix that.

non issue

Most helpful comment

If you do need that you can always Joi.number().min(0).

All 4 comments

If you do need that you can always Joi.number().min(0).

joi.number().positive().allow(0)

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergibondarenko picture sergibondarenko  路  3Comments

ashrafkm picture ashrafkm  路  3Comments

builtbybrayne picture builtbybrayne  路  4Comments

jamesdixon picture jamesdixon  路  4Comments

alekbarszczewski picture alekbarszczewski  路  3Comments