# isValidUnixRange

Industry: Core

## Signature

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

Return true if `value1` and `value2` form a valid Unix range — both safe-integer epochs and `value1 < value2` (or `<=` with `allowEqual`).

- Each input must be a safe integer (`Number.isSafeInteger`) or a string of optionally negative ASCII digits naming one — the epoch grammar every `unix/` function shares.
- Fractional values, `NaN`, `±Infinity` and anything beyond ±(2^53 − 1) return `false`.
- Strings with whitespace, `+`, a decimal point, an exponent or hex digits return `false`, and an empty string is not epoch 0.

## Options

**props**

the two epoch values and the settings for the check

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `value1` | `string` \| `number` | Required | The start of the range: a Unix epoch in seconds or milliseconds, as a safe integer or a digit string. |
| `value2` | `string` \| `number` | Required | The end of the range, in the same form and unit as `value1`. |
| `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

boolean indicating whether the Unix range is valid

## Examples

```ts
import { isValidUnixRange } from "@northguild/gmt/unix/validate";

isValidUnixRange({ value1: 0, value2: 1700000000 }) // true
```

## Source

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