Skip Menu |

This queue is for tickets about the MooseX-Types-Common CPAN distribution.

Report information
The Basics
Id: 53234
Status: resolved
Priority: 0/
Queue: MooseX-Types-Common

People
Owner: Nobody in particular
Requestors: ikegami [...] adaelis.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.001000
Fixed in: 0.001003



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" };