added Reaction::Types::CreditCard
wreis [Mon, 14 Jan 2008 20:17:35 +0000 (20:17 +0000)]
Makefile.PL
lib/Reaction/Types/CreditCard.pm [new file with mode: 0644]

index d4def09..b73726c 100644 (file)
@@ -31,6 +31,7 @@ requires 'Email::MIME::Creator';
 requires 'Text::CSV_XS';
 requires 'Devel::Declare' => '0.001006';
 requires 'MooseX::Types' => '0.04';
+requires 'Business::CreditCard' => '0.30';
 
 catalyst;
 
diff --git a/lib/Reaction/Types/CreditCard.pm b/lib/Reaction/Types/CreditCard.pm
new file mode 100644 (file)
index 0000000..ec7de56
--- /dev/null
@@ -0,0 +1,44 @@
+package Reaction::Types::CreditCard;
+
+use MooseX::Types
+    -declare => [qw/CardNumber/];
+
+use Reaction::Types::Core 'NonEmptySimpleStr';
+use Business::CreditCard;
+
+subtype 'CardNumber'
+    => as 'NonEmptySimpleStr'
+    => where   { Business::CreditCard->validate($_) }
+    => message {"Must be a valid card number"};
+
+1;
+
+=head1 NAME
+
+Reaction::Types::CreditCard
+
+=head1 DESCRIPTION
+
+=over
+
+=item * CardNumber
+
+=back
+
+=head1 SEE ALSO
+
+=over
+
+=item * L<Reaction::Types::Core>
+
+=back
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut