creditCardExpirationDate static method

FormFieldValidator<String> creditCardExpirationDate({
  1. bool checkForExpiration = true,
  2. RegExp? regex,
  3. String? errorText,
  4. bool checkNullOrEmpty = true,
})

FormFieldValidator that requires the field's value to be a valid credit card expiration date.

Parameters:

  • checkForExpiration Whether the expiration date should be checked
  • regex The regex pattern to match.
  • errorText The error message when the expiration date is invalid.
  • checkNullOrEmpty Whether to check for null or empty values.

This regex matches credit card expiration dates.

  • It checks for a valid month (01-12).
  • It checks for a valid year (two digits).

Examples: 01/23, 12/25

Implementation

static FormFieldValidator<String> creditCardExpirationDate({
  bool checkForExpiration = true,
  RegExp? regex,
  String? errorText,
  bool checkNullOrEmpty = true,
}) => CreditCardExpirationDateValidator(
  checkForExpiration: checkForExpiration,
  regex: regex,
  errorText: errorText,
  checkNullOrEmpty: checkNullOrEmpty,
).validate;