# isValidZonedRange

Industry: Core

## Signature

```ts
isValidZonedRange(props: { value1: string; value2: string; options?: { allowEqual?: boolean; }; }): boolean
```

Return true if `value1` and `value2` form a valid zoned range — both parseable as ISO ZonedDateTime strings and the instant at `value1` is &lt;= the instant at `value2`.

- Both inputs must be valid ISO 8601 zoned datetime strings in extended format, as `isValidZonedDateTime` requires: basic format, a space or lower-case `t` separator, a lower-case `z` and a date without a time return `false`.
- Comparison is done by instant, so intervals spanning DST transitions are compared by absolute time.
- Invalid input, malformed strings, or leap-second strings return `false`.
- Each endpoint is read as `isValidZonedDateTime` reads it: a calendar or elective annotation returns `false`.

## Options

**props**

the two endpoints of the range and its optional settings

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `value1` | `string` | Required | The start of the range, as an ISO 8601 zoned datetime string. |
| `value2` | `string` | Required | The end of the range, as an ISO 8601 zoned datetime string. |
| `options?` | `object` | None. Two values at the same instant 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` at the same instant as `value2` is a valid range. `false` requires `value1` to be before `value2`. |

## Returns

boolean indicating whether the zoned range is valid

## Examples

```ts
import { isValidZonedRange } from "@northguild/gmt/zoned/validate";

isValidZonedRange({ value1: "2024-01-01T10:00:00+00:00[UTC]", value2: "2024-12-31T23:59:59+00:00[UTC]" }) // true
```

## Source

[zoned/validate/isValidZonedRange.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/zoned/validate/isValidZonedRange.ts)
