Package com.example.lottery.util
Class EventValidationUtils
java.lang.Object
com.example.lottery.util.EventValidationUtils
Utility class for validating event-related data.
Provides reusable logic for checking business rules defined in user stories.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisDrawDateValid(Date drawDate, Date regEnd, Date eventStart) Validates the draw date against the rest of the event timeline.static booleanisEventEndDateValid(Date startDate, Date endDate) Validates that the event end date is after the event start date.static booleanisRegistrationDeadlineValid(Date deadline, Date eventDate) Validates if the registration deadline occurs before the event start time.static booleanisRegistrationStartValid(Date regStart, Date regEnd) Validates that registration start is before registration end.
-
Constructor Details
-
EventValidationUtils
public EventValidationUtils()
-
-
Method Details
-
isRegistrationDeadlineValid
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
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
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
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 inEventAdapter.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.
-