isValidDutyLog
Signature
Section titled “Signature”isValidDutyLog(log: unknown): booleanValidate whether a value is a duty log every duty/ function accepts.
- True for an array of
{ status, start, end }entries wherestatusis a string andstartandendare ISO 8601 instant strings (offset required, no leap second),endafterstart. - Entries must be ordered by
startand 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
duty/function returns its sentinel for a log this rejects. - Returns
falsefor 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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
log | unknown | candidate array of { status, start, end } records |
Returns
Section titled “Returns”boolean indicating whether the log is valid
Examples
Section titled “Examples”import { isValidDutyLog } from "@northguild/gmt/duty/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