masterCard static method
Validates whether the given cardNumber
is a valid MasterCard number.
The cardNumber
parameter should be a string representing a MasterCard number.
Returns true
if the cardNumber
is valid, false
otherwise.
Implementation
static bool masterCard(String cardNumber) {
String pattern =
r'^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$';
RegExp regExp = RegExp(pattern);
return regExp.hasMatch(cardNumber);
}