pastDate static method
Validates that date is in the past
Example:
Validators.pastDate('2020-01-15');
Implementation
static String? pastDate(String? value, {String? message}) {
if (value == null || value.isEmpty) return null;
try {
final date = DateTime.parse(value);
if (!date.isBefore(DateTime.now())) {
return message ?? 'Date must be in the past';
}
return null;
} catch (_) {
return message ?? 'Please enter a valid date';
}
}