Skip to content

feat: added validation for shiftAttendance#253

Open
ajablaza wants to merge 3 commits intomainfrom
ajablaza/feature/apply-shift-validation
Open

feat: added validation for shiftAttendance#253
ajablaza wants to merge 3 commits intomainfrom
ajablaza/feature/apply-shift-validation

Conversation

@ajablaza
Copy link
Copy Markdown
Collaborator

@ajablaza ajablaza commented Mar 28, 2026

feat: Add attendance check-in/out validation to completeShift

Summary

Adds guard attendance validation to the completeShift route, preventing a shift from being marked complete unless the assigned guard has both checked in and checked out.

Changes

Shift Model (Shift.js)

  • Added attendance virtual populate referencing ShiftAttendance via shiftId
  • Added hasCheckedIn virtual — returns true if attendance.checkInTime is not null
  • Added hasCheckedOut virtual — returns true if attendance.checkOutTime is not null

completeShift Route

  • Returns 400 with 'Guard has not checked in' if hasCheckedIn is false
  • Returns 400 with 'Guard has not checked out' if hasCheckedOut is false

Why

Previously, a shift could be completed without any attendance record, which could lead to inaccurate shift data. This validation ensures attendance is properly recorded before a shift is closed out.

Test Cases:
Unable to mark complete without guard checkin
image

Unable to mark complete without guard checkout
image

Shift completed after complete checkin/checkout from guard
image

@ajablaza ajablaza requested a review from uppalkrish March 28, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant