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

Marsup picture Marsup  路  30Comments

skiwi2 picture skiwi2  路  19Comments

rooftopsparrow picture rooftopsparrow  路  21Comments

hueniverse picture hueniverse  路  19Comments

ThisIsMissEm picture ThisIsMissEm  路  33Comments