aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/Types
diff options
context:
space:
mode:
authorwreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-26 15:21:51 +0000
committerwreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-26 15:21:51 +0000
commitab5789054f8e4be94f652d364558ae7ba8586cd7 (patch)
treed17a2dd4cbceed5ccf83f0551e88388198c6ec16 /lib/Reaction/Types
parent90b1c70a06978e81a7f29c04a7dc6d0b17791081 (diff)
downloadreaction-ab5789054f8e4be94f652d364558ae7ba8586cd7.tar.gz
reaction-ab5789054f8e4be94f652d364558ae7ba8586cd7.zip
added CheckNumber type constraint
Diffstat (limited to 'lib/Reaction/Types')
-rw-r--r--lib/Reaction/Types/CreditCard.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Reaction/Types/CreditCard.pm b/lib/Reaction/Types/CreditCard.pm
index 81ddfcd..f733355 100644
--- a/lib/Reaction/Types/CreditCard.pm
+++ b/lib/Reaction/Types/CreditCard.pm
@@ -1,16 +1,21 @@
package Reaction::Types::CreditCard;
use MooseX::Types
- -declare => [qw/CardNumber/];
+ -declare => [qw/CardNumber CheckNumber/];
-use Reaction::Types::Core 'NonEmptySimpleStr';
+use Reaction::Types::Core qw/NonEmptySimpleStr PositiveInt/;
use Business::CreditCard ();
-subtype 'CardNumber'
- => as 'NonEmptySimpleStr'
+subtype CardNumber
+ => as NonEmptySimpleStr
=> where { Business::CreditCard::validate($_) }
=> message {"Must be a valid card number"};
+subtype CheckNumber
+ => as PositiveInt
+ => where { $_ <= 999 }
+ => message { "Must be a 3 digits number" };
+
1;
=head1 NAME