Subject: | Zero isn't positive or negative |
PositiveNum, PositiveInt, NegativeNum and NegativeInt all match zero when they shouldn't.
Fix:
subtype PositiveNum,
as Num,
where { $_ > 0 },
message { "Must be a positive number" };
subtype PositiveInt,
as Int,
where { $_ > 0 },
message { "Must be a positive integer" };
subtype NonNegativeNum,
as Num,
where { $_ >= 0 },
message { "Must be a non-negative number" };
subtype NonNegativeInt,
as Int,
where { $_ >= 0 },
message { "Must be a non-negative integer" };
subtype NegativeNum,
as Num,
where { $_ < 0 },
message { "Must be a negative number" };
subtype NegativeInt,
as Int,
where { $_ < 0 },
message { "Must be a negative integer" };
subtype NonPositiveNum,
as Num,
where { $_ <= 0 },
message { "Must be a non-positive number" };
subtype NonPositiveInt,
as Int,
where { $_ <= 0 },
message { "Must be a non-positive integer" };
subtype SingleDigit,
as NonNegativeInt,
where { $_ <= 9 },
message { "Must be a single digit" };
Fix:
subtype PositiveNum,
as Num,
where { $_ > 0 },
message { "Must be a positive number" };
subtype PositiveInt,
as Int,
where { $_ > 0 },
message { "Must be a positive integer" };
subtype NonNegativeNum,
as Num,
where { $_ >= 0 },
message { "Must be a non-negative number" };
subtype NonNegativeInt,
as Int,
where { $_ >= 0 },
message { "Must be a non-negative integer" };
subtype NegativeNum,
as Num,
where { $_ < 0 },
message { "Must be a negative number" };
subtype NegativeInt,
as Int,
where { $_ < 0 },
message { "Must be a negative integer" };
subtype NonPositiveNum,
as Num,
where { $_ <= 0 },
message { "Must be a non-positive number" };
subtype NonPositiveInt,
as Int,
where { $_ <= 0 },
message { "Must be a non-positive integer" };
subtype SingleDigit,
as NonNegativeInt,
where { $_ <= 9 },
message { "Must be a single digit" };