isCvnValidForCardType static method
Determines whether the card CVN length is valid
@param cardCVN The credit card CVN @param cardNumber The credit card number @return true if the cvn length is valid for this card type, false otherwise
Implementation
static bool isCvnValidForCardType(String? cardCVN, String? cardNumber) {
if (cardCVN == null || cardNumber == null) {
return false;
}
String ccvn = cleanCvn(cardCVN);
String ccn = cleanCardNumber(cardNumber);
if (_isNumeric(ccvn) && int.parse(ccvn) >= 0) {
return _isCardAmex(ccn) ? ccvn.length == 4 : ccvn.length == 3;
}
return false;
}