isDateValid function
Implementation
String isDateValid({required String? date}) {
if (date == null || date.trim().isEmpty) {
return 'Date should not be blank to get Kural of the Day.';
}
try {
final inputFormat = DateFormat('dd-MM-yyyy');
inputFormat.parseStrict(date.trim());
return ''; // Valid
} catch (_) {
return 'Invalid date. Please provide the date in DD-MM-YYYY format.';
}
}