Skip to content

isValidDutyLog

  • People's working time: duty logs, hours-of-work limits, rest and rolling windows, for any crew, shift or rota.
isValidDutyLog(log: unknown): boolean

Validate whether a value is a duty log every workforce/ function accepts.

  • True for an array of { status, start, end } entries where status is a string and start and end are ISO 8601 instant strings (offset required, no leap second), end after start.
  • Entries must be ordered by start and must not overlap. One may start exactly where the previous one ends, since entries are half-open, or later, leaving a gap. Order is by instant, not text.
  • [] is a valid, empty log. Extra keys on an entry are ignored.
  • Every other workforce/ function returns its sentinel for a log this rejects.
  • Returns false for a non-array, an entry that is not an object, a non-string status, a bound that is not an instant, a zero-length or inverted entry, and entries out of order or overlapping.
ParameterTypeDescription
logunknowncandidate array of { status, start, end } records

boolean indicating whether the log is valid

import { isValidDutyLog } from "@northguild/gmt/workforce/validate";
isValidDutyLog([{ status: "off", start: "2024-01-01T00:00:00Z", end: "2024-01-01T10:00:00Z" }, { status: "driving", start: "2024-01-01T10:00:00Z", end: "2024-01-01T15:00:00Z" }]) // true
output 

workforce/validate/isValidDutyLog.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.