isCreditCardExpirationDate method
Check if the string is a valid credit card expiration date.
Implementation
bool isCreditCardExpirationDate(String value) {
// Check if the format matches MM/YY
if (!regex.hasMatch(value)) {
return false;
}
// Extract month and year from the value
final List<int> parts = value.split('/').map(int.parse).toList();
final int month = parts[0];
final int year = parts[1];
// Check for valid month (1-12)
if (month < 1 || month > 12) {
return false;
}
return year > 0;
}