validateCardNumber static method
Валидация номера карты
Implementation
static bool validateCardNumber(String cardNumber) {
if (cardNumber.isEmpty ||
!CardSettings.cardNumberPattern.hasMatch(cardNumber)) {
return false;
}
final CardPaymentSystem cardType =
CardPaymentSystemX.resolvePaymentSystem(cardNumber);
final List<int> allowedLengthRanges = cardType.getLengthRanges;
bool isLengthAllowed = false;
for (final int allowedLength in allowedLengthRanges) {
if (cardNumber.length == allowedLength) {
isLengthAllowed = true;
}
}
return isLengthAllowed && _validateWithLuhnAlgorithm(cardNumber);
}