.positive() accepts 0, but shouldn't 0 not be considered a positive number?
probably!
Maybe not!
"An integer is positive if it is greater than zero and negative if it is less than zero. Zero is defined as neither negative nor positive"
https://en.wikipedia.org/wiki/Integer
So, zero is not positive, so, yes, this is a bug. The workaround (ugh!)
yup.number().moreThan(0)
Same problem, curious that the issue was opened so recently.
moreThan (and lessThan for negative) rather than min and max.I know it's closed and it will probably stay that way now, but to me, 0 is positive and negative. I even remember a weird math programming language calling x > 0 a non negative integer. Moreover, some languages define a +0 and a -0.
That said, I think there should be mention of that change somewhere in the changelog, because I almost broke my app by upgrading from 0.25 to 0.26 after looking at the changelog and I will certainly not be the only one...
@maxaggedon zero is by definition not negative and not positive. http://www.math.com/school/subject1/lessons/S1U1L10DP.html But yes this should be added to changelog.
So I have tried yup.number().moreThan(0) but that is exclusive, thus 0 itself is not included. Working on a schema right now that needs all positive real numbers, OR 0.
I also cannot use .moreThan(-1), as numbers like -0.0001 are true.
Is there any way yup could get a .or chainable function?
@iPwnPancakes isn't number().min(0) what you need ?
.....maybe
Yes it is 馃ぃ Appreciate the help
moreThan(-1) is this correct?
payment: Yup.number()
.required('Required')
.moreThan(-1, 'Enter valid Amount')
.typeError('Enter valid Amount'),
Most helpful comment
@iPwnPancakes isn't
number().min(0)what you need ?