isValidDateRange
Signature
Section titled “Signature”isValidDateRange(props: IsValidDateRangeProps): booleanReturn whether value1 is before value2.
- Validates both dates with
isValidDate, so each endpoint’s RFC 9557 annotations are read asTemporal.PlainDate.fromreads them (an elective[foo=bar]or[u-ca=iso8601]is ignored). - Rejects leap seconds in either date.
Options
Section titled “Options”props
The two values to compare and how equal values are treated
The argument object of isValidDateRange.
import type { IsValidDateRangeProps } from "@northguild/gmt";| Option | Type | Default | Description |
|---|---|---|---|
value1 | string | Required | The start of the range, an ISO PlainDate string. |
value2 | string | Required | The end of the range, an ISO PlainDate 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 date range is valid
Examples
Section titled “Examples”import { isValidDateRange } from "@northguild/gmt/plain/validate";
isValidDateRange({ value1: "2024-02-28", value2: "2024-02-29" }) // true