X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FCommon%2FNumeric.pm;h=af9e01a66ba35dd6b5e5f088648308737cbb5347;hb=d0b8bc7f34ec718fae7804257ed3db44c126ebd7;hp=17127a28b56e7eb43dc11599b3733952151e5a4b;hpb=ac73ab52030a0e37e78c715d880d92cdb8f4b0ed;p=gitmo%2FMooseX-Types-Common.git diff --git a/lib/MooseX/Types/Common/Numeric.pm b/lib/MooseX/Types/Common/Numeric.pm index 17127a2..af9e01a 100644 --- a/lib/MooseX/Types/Common/Numeric.pm +++ b/lib/MooseX/Types/Common/Numeric.pm @@ -3,7 +3,7 @@ package MooseX::Types::Common::Numeric; use strict; use warnings; -our $VERSION = '0.001000'; +our $VERSION = '0.001001'; use MooseX::Types -declare => [ qw(PositiveNum PositiveInt NegativeNum NegativeInt SingleDigit) @@ -13,38 +13,71 @@ use MooseX::Types::Moose qw/Num Int/; subtype PositiveNum, as Num, - where { $_ >= 0 }, - message { "Must be a positive number" }; + where { $_ > 0 }, + message { "Must be a positive number" }, + ( $Moose::VERSION >= 2.0200 + ? inline_as { + $_[0]->parent()->_inline_check( $_[1] ) . ' && ' + . qq{ ($_[1] > 0) }; + } + : () + ); subtype PositiveInt, as Int, - where { $_ >= 0 }, - message { "Must be a positive integer" }; + where { $_ > 0 }, + message { "Must be a positive integer" }, + ( $Moose::VERSION >= 2.0200 + ? inline_as { + $_[0]->parent()->_inline_check( $_[1] ) . ' && ' + . qq{ ($_[1] > 0) }; + } + : () + ); subtype NegativeNum, as Num, - where { $_ <= 0 }, - message { "Must be a negative number" }; + where { $_ < 0 }, + message { "Must be a negative number" }, + ( $Moose::VERSION >= 2.0200 + ? inline_as { + $_[0]->parent()->_inline_check( $_[1] ) . ' && ' + . qq{ ($_[1] < 0) }; + } + : () + ); subtype NegativeInt, as Int, - where { $_ <= 0 }, - message { "Must be a negative integer" }; + where { $_ < 0 }, + message { "Must be a negative integer" }, + ( $Moose::VERSION >= 2.0200 + ? inline_as { + $_[0]->parent()->_inline_check( $_[1] ) . ' && ' + . qq{ ($_[1] < 0) }; + } + : () + ); subtype SingleDigit, as PositiveInt, where { $_ <= 9 }, - message { "Must be a single digit" }; - + message { "Must be a single digit" }, + ( $Moose::VERSION >= 2.0200 + ? inline_as { + $_[0]->parent()->_inline_check( $_[1] ) . ' && ' + . qq{ ($_[1] <= 9) }; + } + : () + ); 1; __END__; - =head1 NAME -MooseX::Types::Common::Numeric +MooseX::Types::Common::Numeric - Commonly used numeric types =head1 SYNOPSIS