Skip to content

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

Description

@erikskoon

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions