CleanCode Perl Libraries |
Home | Perl | Java | PowerShell | C# | SQL | Index | Tools | Download | What's New |
Multi-Lingual Library | Maintainability | ||||||||||||
Perl | Java | JavaScript | Certified Class |
Testable Class |
Standalone Mode |
Diagnostic Enabled |
CGI::PageValidator::Plugin::CreditCardNum - verifies a credit card number is valid for a given credit card type and has a valid checksum.
(See the Note on Plugins in the CheckItem class for usage notes.)
use CGI::PageValidator::Plugin::CreditCardNum;
$pluginObj=CGI::PageValidator::Plugin::CreditCardNum->new($libItem,
"CCType", "4285123412341234", "visa", "CGI::PageValidator::PluginLib");
$pluginObj->examine();
$errMsg = $pluginObj->getResult();
CGI::PageValidator::Plugin
Perl5.005, CGI::PageValidator::Plugin
Dependent fields: CCType
This plugin examines a credit card number and type and performs two tests:
Does the number fit the pattern for the specified type? Ex. Discover must have a certain number of digits and begin with '4', etc.
Does the card number checksum compute correctly? All credit cards (supposedly) under 19 digits use the Luhn Mod-10 checksum.
This plugin uses a small custom library CCLib that provides a pattern for each credit card type to match against. (This library, like the main validation library, is auto-generated from the JavaScript version in order to maintain only a single copy.)
This code is loosely based on a sample credit card validation from Netscape (originally at developer.netscape.com/docs/examples/javascript/regexp/overview.html but this link is no longer available).
None
Michael Sorens
$Revision: 8 $ $Date: 2006-12-19 21:13:43 -0800 (Tue, 19 Dec 2006) $
CleanCode 0.9
Home | Perl | Java | PowerShell | C# | SQL | Index | Tools | Download | What's New |
CleanCode Perl Libraries | Copyright © 2001-2013 Michael Sorens - Revised 2013.06.30 |