validateCVV static method

String? validateCVV(
  1. String? value
)

Validate CVV/CVC

Implementation

static String? validateCVV(String? value) {
  if (value == null || value.isEmpty) {
    return 'CVV is required.';
  }

  final cvvRegExp = RegExp(r'^\d{3,4}$');
  if (!cvvRegExp.hasMatch(value)) {
    return 'Invalid CVV format (3 or 4 digits).';
  }

  return null;
}