# isValidSpan

Industry: Core

## Signature

```ts
isValidSpan(start: string, end: string): boolean
```

Validate whether two ISO 8601 instant strings form a measurable span.

- True exactly when `spanMs` and `spanNs` will return a value rather than `null` — the endpoints both parse, so there is an elapsed time between them.
- Accepts what `toNanoseconds` does on both sides: an offset designator is required, and nothing after it; no leap seconds. An annotation of any kind (a time zone, a calendar, an elective one) returns `false`. The offset alone fixes the instant.
- Order does not matter. A span is signed, not invalid, when `start` is after `end`, so this is symmetric.
- **`spanMs` can still return `null` on a pair this accepts** — a span wider than `Number.MAX_SAFE_INTEGER` milliseconds has no `number` to return. That is a range limit on the result, not a defect in the inputs, and `spanNs` returns the exact `bigint` for the same pair.
- Does **not** validate `spanWallClock`, which needs a bracketed IANA zone on both endpoints rather than a bare offset — that is `isValidZonedDateTime`.
- Returns `false` for non-strings and empty strings.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `start` | `string` | candidate ISO 8601 instant string the span would be measured from |
| `end` | `string` | candidate ISO 8601 instant string the span would be measured to |

## Returns

boolean indicating whether spanMs/spanNs will measure this pair

## Examples

```ts
import { isValidSpan } from "@northguild/gmt/span/validate";

isValidSpan("2024-03-10T12:00:00Z", "2024-03-10T12:00:01Z") // true
```

## Source

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