Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
use numeric code to validate digits
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Cushing <xenoterracide@gmail.com>
  • Loading branch information
xenoterracide committed May 17, 2012
1 parent d22cfe4 commit 43b1297
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/MooseX/Types/CreditCard.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ use warnings;


use MooseX::Types -declare => [ qw( CreditCard CardSecurityCode ) ]; use MooseX::Types -declare => [ qw( CreditCard CardSecurityCode ) ];
use MooseX::Types::Moose qw( Str Int ); use MooseX::Types::Moose qw( Str Int );
use MooseX::Types::Common::String 0.001005 qw( NumericCode );
use namespace::autoclean; use namespace::autoclean;


use Business::CreditCard; use Business::CreditCard;


subtype CreditCard, subtype CreditCard,
as Str, as NumericCode,
where { where {
length($_) <= 20 length($_) <= 20
&& length $_ >= 12 && length $_ >= 12
&& $_ =~ /^[0-9]+$/xms
&& validate($_) && validate($_)
}, },
message {'"'. $_ . '" is not a valid credit card number' } message {'"'. $_ . '" is not a valid credit card number' }
Expand All @@ -32,7 +32,7 @@ coerce CreditCard,
; ;


subtype CardSecurityCode, subtype CardSecurityCode,
as Str, as NumericCode,
where { where {
length $_ >= 3 length $_ >= 3
&& length $_ <= 4 && length $_ <= 4
Expand Down

0 comments on commit 43b1297

Please sign in to comment.