validate method
Validates the provided data against this rule.
Returns true if the data is valid, false otherwise.
Subclasses must implement this method.
Implementation
@override
bool validate(data) {
if (data is DateTime) {
final now = DateTime.now();
int ageInYears = now.year - data.year;
// Adjust if birthday hasn't occurred yet this year
if (now.month < data.month ||
(now.month == data.month && now.day < data.day)) {
ageInYears--;
}
return ageInYears > age;
}
return false;
}