Skip to content

feat: added validation for shiftAttendance#253

Merged
uppalkrish merged 4 commits intomainfrom
ajablaza/feature/apply-shift-validation
Apr 16, 2026
Merged

feat: added validation for shiftAttendance#253
uppalkrish merged 4 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
@uppalkrish
Copy link
Copy Markdown
Collaborator

Good work!

@uppalkrish uppalkrish merged commit 347df94 into main Apr 16, 2026
1 of 2 checks passed
@uppalkrish uppalkrish deleted the ajablaza/feature/apply-shift-validation branch April 16, 2026 23:07
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.

2 participants