String validation tools.
Checks if a string is a valid credit card number and fits a specific brand pattern.
Source: http://www.regular-expressions.info/creditcard.html
string
creditcard
string
String
creditcard
String
A credit card brand abbreviation. Possible values are visa, mastercard, americanexpress, dinersclub, discover, jcb.
If true, the string is a valid credit card number.
kafe.string.validate.isCreditCard('k789 kafe 3789', 'mc');
// returns false
kafe.string.validate.isCreditCard('1234 5678 1234 5678', 'vi');
// returns true
Checks if a string is a valid email address.
string
string
String
If true, the string is a valid email address.
kafe.string.validate.isEmail('mailbox@mailaddress');
// returns false
kafe.string.validate.isEmail('kafe.feedback@absolunet.com');
// returns true
Checks if a string passes the Luhn algorithm.
Source: https://gist.github.com/2134376 Source: http://jsperf.com/credit-card-validator/7
string
string
String
If true, the string passes the Luhn algorithm.
kafe.string.validate.isLuhn('79927398713');
// returns true
Checks if a string is numeric.
string
string
String
If true, the string could be converted to a number.
kafe.string.validate.isNum('k4f3');
// returns false
kafe.string.validate.isNum('43');
// returns true
Checks if a string is a valid or part of a valid Canadian postal code.
string
format] Validation pattern (Regular expression). Default pattern is *([a-z][0-9
string
String
[format] Validation pattern (Regular expression). Default pattern is *([a-z][0-9]
String
Optional
){3}*. Can also be set to A1A 1A1 for a single precise value or as A1A and 1A1 when divided into two values.
If true, the string matches the validation format.
kafe.string.validate.isPostalCode('KAF123');
// returns false
kafe.string.validate.isPostalCode('K4F 3F3', 'A1A 1A1');
// returns true