isCvnValid static method

bool isCvnValid(
  1. String cardCVN
)

Determines whether the card CVN is valid

@param cardCVN The credit card CVN @return true if the cvn is valid, false otherwise

Implementation

static bool isCvnValid(String cardCVN) {
  if (cardCVN.isEmpty) {
    return false;
  }

  String ccvn = cleanCvn(cardCVN);

  return _isNumeric(ccvn) &&
      int.parse(ccvn) >= 0 &&
      ccvn.length >= 3 &&
      ccvn.length <= 4;
}