validate method

  1. @override
void validate()

Validates the calendar schedule settings.

Throws an AwesomeNotificationsException if no schedule time condition is provided or if any condition is negative. Throws an UnimplementedError if weekOfMonth is not null as it's not fully implemented.

Implementation

@override
void validate() {
  if (era == null &&
      year == null &&
      month == null &&
      day == null &&
      hour == null &&
      minute == null &&
      second == null &&
      weekday == null &&
      weekOfMonth == null &&
      weekOfYear == null) {
    throw const AwesomeNotificationsException(
        message: 'At least one shedule time condition is required.');
  }

  if (weekOfMonth != null) {
    throw UnimplementedError("weekOfMonth is not fully implemented yet");
  }

  if ((era ?? 0) < 0 ||
      (year ?? 0) < 0 ||
      (month ?? 0) < 0 ||
      (day ?? 0) < 0 ||
      (hour ?? 0) < 0 ||
      (minute ?? 0) < 0 ||
      (second ?? 0) < 0 ||
      (weekday ?? 0) < 0 ||
      (weekOfMonth ?? 0) < 0 ||
      (weekOfYear ?? 0) < 0) {
    throw const AwesomeNotificationsException(
        message:
            'A shedule time condition must be greater or equal to zero.');
  }
}