cvvValidator static method
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;
}