toDateValidation static method

String? toDateValidation({
  1. required String fromDate,
  2. required String toDate,
})

Implementation

static String? toDateValidation(
    {required String fromDate, required String toDate}) {
  if (toDate.isEmpty) return "Required";
  if (fromDate.isEmpty) return "Start Date is required";
  if (fromDate.length != 10 || !isValidDate("MM-dd-yyyy", fromDate))
    return "Enter valid start date";
  if (isTodayOrLess(fromDate, "MM-dd-yyyy")!)
    return "Start date should not exceed end date / today";
  if (toDate.length != 10 || !isValidDate("MM-dd-yyyy", toDate))
    return "Enter valid end date";
  if (!validateDates(fromDate, toDate))
    return "End date should be greater than start date.";
  if (isTodayOrLess(toDate, "MM-dd-yyyy")!)
    return "To date should be less than or equal to today";
  return null;
}