checForOneDayEventFormValidation method

dynamic checForOneDayEventFormValidation(
  1. EventNotificationModel eventData
)

Implementation

dynamic checForOneDayEventFormValidation(EventNotificationModel eventData) {
  if (eventData.event!.date == null) {
    return 'add event date';
  }
  if (eventData.event!.endDate == null) {
    return 'add event date';
  }
  if (eventData.event!.startTime == null) {
    return 'add event start time';
  }
  if (eventData.event!.endTime == null) {
    return 'add event end time';
  }
  if (!isEventUpdate) {
    if (eventData.event!.startTime!.difference(DateTime.now()).inMinutes <
        0) {
      return 'Start Time cannot be in past';
    }
  }

  if (eventData.event!.endTime!.difference(DateTime.now()).inMinutes < 0) {
    return 'End Time cannot be in past';
  }

  if (eventData.event!.endTime!
          .difference(eventData.event!.startTime!)
          .inMinutes <
      0) {
    return 'Start time cannot be after End time';
  }

  if (eventData.event!.endTime == eventData.event!.startTime) {
    return 'Start time and End time cannot be same';
  }
  return true;
}