americanExpressCard static method
Validates whether the given cardNumber
is a valid American Express card number.
The cardNumber
parameter should be a string representing an American Express card number.
Returns true
if the cardNumber
is valid, false
otherwise.
Implementation
static bool americanExpressCard(String cardNumber) {
String pattern = r'^3[47][0-9]{13}$';
RegExp regExp = RegExp(pattern);
return regExp.hasMatch(cardNumber);
}