isValid method
Implementation
@override
bool isValid(String value) {
String v = value.replaceAll(RegExp(r'\D'), '');
if (v.length != 4) {
return false;
}
int? monthNum = int.tryParse(v.substring(0, 2));
if (monthNum == null || monthNum < 1 || monthNum > 12) {
return false;
}
int? yearNum = int.tryParse(v.substring(2));
if (yearNum == null) {
return false;
}
yearNum += 2000;
return DateTime(yearNum, monthNum).isAfter(DateTime.now().monthFirstDay);
}