Validity style validator to validate payment card numbers with the luhn algorithm. Defers the luhn module for the validity check and prevents the use of test credit card numbers.
Note that this validity check only ensures that the credit card might be valid based on the pattern of digits (as opposed to a random string). See the Wikipedia article on the Luhn algorithm for more info.
npm install validity-payment-card-number
Below is a simple example for usage with schemata and save:
var validity =schemata =save =collection =createCardValidator =var schema =
Create a validate function.
allowTestCards is used by the tests (because I'm not
putting my valid card numbers in this repo!). Although payment will fail if used,
You should obviously not set this when validating real card numbers in case
someone sneakily tries to use a test card number.
This is a validity compatible function, which in turn is used by schemata for schema validation.
The callback signature cb(err, errorMessage).
err is an Error object if something bad happened and null otherwise. errorMessage is a String if a validation error happened and undefined otherwise.
Licensed under the New BSD License