Class EventValidationUtils

java.lang.Object
com.example.lottery.util.EventValidationUtils

public class EventValidationUtils extends Object
Utility class for validating event-related data. Provides reusable logic for checking business rules defined in user stories.
  • Constructor Details

    • EventValidationUtils

      public EventValidationUtils()
  • Method Details

    • isRegistrationDeadlineValid

      public static boolean isRegistrationDeadlineValid(Date deadline, Date eventDate)
      Validates if the registration deadline occurs before the event start time. Required by US 02.01.04.
      Parameters:
      deadline - The registration deadline date.
      eventDate - The scheduled start date of the event.
      Returns:
      true if the deadline is strictly before the event date, false otherwise or if either is null.
    • isEventEndDateValid

      public static boolean isEventEndDateValid(Date startDate, Date endDate)
      Validates that the event end date is after the event start date.
      Parameters:
      startDate - The event start date.
      endDate - The event end date.
      Returns:
      true if endDate is strictly after startDate, or if either is null (optional fields).
    • isRegistrationStartValid

      public static boolean isRegistrationStartValid(Date regStart, Date regEnd)
      Validates that registration start is before registration end.
      Parameters:
      regStart - The registration start date.
      regEnd - The registration end date.
      Returns:
      true if regStart is strictly before regEnd, or if either is null (optional fields).
    • isDrawDateValid

      public static boolean isDrawDateValid(Date drawDate, Date regEnd, Date eventStart)
      Validates the draw date against the rest of the event timeline. The draw date is required: it must happen strictly after registration closes (so registration is already closed when the draw runs) and on or before the event start (so the draw does not run after attendees have already shown up). Events without a draw date also disappear from the pending_draw workflow in EventAdapter.resolveDisplayStatus(com.example.lottery.model.Event), so null is explicitly rejected here.
      Parameters:
      drawDate - The draw date to validate (required).
      regEnd - Registration deadline.
      eventStart - Scheduled event start.
      Returns:
      true only if all three dates are non-null, drawDate is strictly after regEnd, and drawDate is not after eventStart.