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