cvvValidator static method

String? cvvValidator(
  1. String? value, [
  2. String? errorMessage
])

cvvValidator to validate CVV

validator: (value) => SimpleValidations.cvvValidator(value, [errorMessage]),

Implementation

static String? cvvValidator(String? value, [String? errorMessage]) {
  RegExp regex = CustomRegEx.cvvRegex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter a valid CVV';
  }
  return null;
}