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

IsPositive accepts 0 while 0 is not a positive number #85

Open
erikskoon opened this issue Dec 21, 2020 · 0 comments
Open

IsPositive accepts 0 while 0 is not a positive number #85

erikskoon opened this issue Dec 21, 2020 · 0 comments

Comments

@erikskoon
Copy link

erikskoon commented Dec 21, 2020

I needed a validation rule that accepts only positive numbers. I saw that the library comes with a validationrule called "IsPositive", great!
Unfortunately when testing it it accepted the value 0, and when I checked the source it validates like: value >= 0.
The number 0 is neither negative or positive.
A rule accepting 0 and all positive numbers should be called isNonNegative, while isPositive should only accept values that are greater than 0.
Same goes for isNegative vs isNonPositive.

Changing this would obviously be a breaking change, however I believe this is very confusing and incorrect. Maybe some documentation should be created where this is mentioned, on top of an addition to the library with a rule isPositiveZeroExcluded or something.

Obviously it is easy to just create this as a custom rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant