isValidTimeRange
Signature
Section titled “Signature”isValidTimeRange(props: { value1: string; value2: string; options?: { allowEqual?: boolean; }; }): booleanReturn true if value1 and value2 form a valid time range — both parseable as ISO PlainTime strings and value1 before value2.
- Both inputs must be ISO 8601 time strings (e.g.
"14:30:00"), asisValidTimeaccepts, annotations included. - Ordered by
Temporal.PlainTime.compare, to the nanosecond. - Invalid input, malformed strings, or leap-second strings return
false.
Options
Section titled “Options”props
The two values to compare and how equal values are treated
| Option | Type | Default | Description |
|---|---|---|---|
value1 | string | Required | The start of the range, an ISO PlainTime string. |
value2 | string | Required | The end of the range, an ISO PlainTime string. |
options? | object | None. Equal values are not a valid range. | The settings for the comparison. It must be an object or omitted; any other value, null included, returns false. |
options.allowEqual? | boolean | false | Whether value1 equal to value2 is a valid range. false requires value1 to be before value2. |
Returns
Section titled “Returns”boolean indicating whether the time range is valid
Examples
Section titled “Examples”import { isValidTimeRange } from "@northguild/gmt/plain/validate";
isValidTimeRange({ value1: "09:00:00", value2: "17:00:00" }) // true