isValidInterval
Signature
Section titled “Signature”isValidInterval(interval: Interval): booleanValidate whether a value is an Interval the interval/ namespace accepts.
- True when
startandendare ISO 8601 instant strings (offset required, no leap second) andstartis not afterend. - A calendar annotation (
[u-ca=hebrew], critical or not) and an elective unknown annotation ([foo=bar]) are ignored, asTemporal.Instant.fromignores them; an unknown critical annotation ([!foo=bar]) is rejected. A bracketed zone is not validated. It is read for one thing: an offset written to the minute that is the zone’s sub-minute offset rounded (-00:45[Africa/Monrovia], for −00:44:30) names the instant the zone gives, asTemporal.ZonedDateTime.fromreads it. - Compares instants, not text:
{ start: "2024-01-01T10:00:00+01:00", end: "2024-01-01T09:30:00Z" }is valid even though it sorts backwards as a string. start === endis valid — an empty interval.- Use it to tell a legitimate
[]frommergeIntervals,subtractIntervalsorsplitIntervalAtapart from their invalid-input sentinel, which is also[]. - Returns
falsefor non-objects,null, and records whosestart/endare not strings.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
interval | Interval | candidate { start, end } record of ISO 8601 instant strings |
Returns
Section titled “Returns”boolean indicating whether every interval/ function accepts it
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidInterval } from "@northguild/gmt/interval/validate";
isValidInterval({ start: "2024-01-01T09:00:00Z", end: "2024-01-01T17:00:00Z" }) // true