Data::FormValidator::Constraints::CreditCard - Data constraints, using Business::CreditCard
use Data::FormValidator::Constraints::CreditCard qw(:all); constraint_methods => { cc_number => [ # number is syntactically valid FV_cc_number(), # verify type, by value FV_cc_type(qw(Visa MasterCard)), # verify type, by regex FV_cc_type(qr/visa|mastercard/i), ], # expiry month is within valid range cc_exp_mon => FV_cc_expiry_month(), # expiry year is not in the past cc_exp_year => FV_cc_expiry_year(), # full expiry date is not in the past cc_expiry => FV_cc_expiry(), },
Data::FormValidator::Constraints::CreditCard provides several methods that can be used to generate constraint closures for use with Data::FormValidator for the purpose of validating credit card numbers and expiry dates, using Business::CreditCard.
Data::FormValidator::Constraints::CreditCard
Data::FormValidator
Business::CreditCard
Creates a constraint closure that returns true if the constrained value appears to be a valid credit card number.
NOTE: "appears to be a valid credit card number" ONLY means that the number appears to be valid and has passed the checksum test; -NO- tests have been performed to verify that this is actually a real/valid credit card number.
Creates a constraint closure that returns true if the constrained value appears to be a credit card of one of the types listed in the given @set. The @set can be provided as either a list of scalars (which are compared using the eq operator), or as a list of regular expressions.
@set
eq
For more information on the actual card types that can be checked for, please refer to the information for the cardtype() method in Business::CreditCard.
cardtype()
Creates a constraint closure that returns true if the constrained value appears to be a valid credit card expiry date; correct integer values for year/month, with the date not being in the past.
Accepted formats include "MM/YY" and "MM/YYYY".
NOTE: use of this method requires that the full credit card expiry date be present in a single field; no facilities are provided for gathering the month/year data from two separate fields.
Creates a constraint closure that returns true if the constrained value appears to be a valid credit card expiry month; an integer in the range of "1-12".
Creates a constraint closure that returns true if the constrained value appears to be a valid credit card expiry year; an integer value for a year, not in the past.
Expiry years can be provided as either "YY" or "YYYY". When using the two-digit "YY" format, the year is considered to be part of the sliding window 1970-2069.
Graham TerMarsch (cpan@howlingfrog.com)
Copyright (C) 2008, Graham TerMarsch. All Rights Reserved.
This is free software; you can redistribute it and/or modify it under the same license as Perl itself.
Data::FormValidator, Business::CreditCard.
To install Data::FormValidator::Constraints::CreditCard, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::FormValidator::Constraints::CreditCard
CPAN shell
perl -MCPAN -e shell install Data::FormValidator::Constraints::CreditCard
For more information on module installation, please visit the detailed CPAN module installation guide.