# isValidInterval

Industry: Core

## Signature

```ts
isValidInterval(interval: Interval): boolean
```

Validate whether a value is an `Interval` the `interval/` namespace accepts.

- True when `start` and `end` are ISO 8601 instant strings (offset required, no leap second) and `start` is not after `end`.
- Accepts no annotation: a time zone, a calendar or an elective one on either endpoint returns `false`. The offset alone fixes the instant, and one written with seconds is read exactly.
- 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 === end` is valid — an empty interval.
- Use it to tell a legitimate `[]` from `mergeIntervals`, `subtractIntervals` or `splitIntervalAt` apart from their invalid-input sentinel, which is also `[]`.
- Returns `false` for non-objects, `null`, and records whose `start`/`end` are not strings.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `interval` | `Interval` | candidate `{ start, end }` record of ISO 8601 instant strings |

## Returns

boolean indicating whether every `interval/` function accepts it

## Related types

- [`Interval`](/gmt/reference/types/Interval/)

## Examples

```ts
import { isValidInterval } from "@northguild/gmt/interval/validate";

isValidInterval({ start: "2024-01-01T09:00:00Z", end: "2024-01-01T17:00:00Z" }) // true
```

## Source

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