isValidUnixRange
Signature
Section titled “Signature”isValidUnixRange(props: { value1: string | number; value2: string | number; options?: { allowEqual?: boolean; }; }): booleanReturn 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 everyunix/function shares. - Fractional values,
NaN,±Infinityand anything beyond ±(2^53 − 1) returnfalse. - Strings with whitespace,
+, a decimal point, an exponent or hex digits returnfalse, and an empty string is not epoch 0.
Options
Section titled “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
Section titled “Returns”boolean indicating whether the Unix range is valid
Examples
Section titled “Examples”import { isValidUnixRange } from "@northguild/gmt/unix/validate";
isValidUnixRange({ value1: 0, value2: 1700000000 }) // true