Permalink
Browse files

use numeric code to validate digits

Signed-off-by: Caleb Cushing <xenoterracide@gmail.com>
  • Loading branch information...
1 parent d22cfe4 commit 43b1297feb9ec7f44679da3d1121bc9a586f3f2d @xenoterracide committed May 17, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/MooseX/Types/CreditCard.pm
@@ -7,16 +7,16 @@ use warnings;
use MooseX::Types -declare => [ qw( CreditCard CardSecurityCode ) ];
use MooseX::Types::Moose qw( Str Int );
+use MooseX::Types::Common::String 0.001005 qw( NumericCode );
use namespace::autoclean;
use Business::CreditCard;
subtype CreditCard,
- as Str,
+ as NumericCode,
where {
length($_) <= 20
&& length $_ >= 12
- && $_ =~ /^[0-9]+$/xms
&& validate($_)
},
message {'"'. $_ . '" is not a valid credit card number' }
@@ -32,7 +32,7 @@ coerce CreditCard,
;
subtype CardSecurityCode,
- as Str,
+ as NumericCode,
where {
length $_ >= 3
&& length $_ <= 4

0 comments on commit 43b1297

Please sign in to comment.