isValidNanoPattern
Signature
Section titled “Signature”isValidNanoPattern(value: string): booleanValidate whether a string is a nanosecond timestamp parseNanoseconds will parse.
parseNanosecondsreturns0nfor both"0"and garbage, so this is how the two are told apart — the check its own JSDoc asks callers to make.- Shape and range: a canonical decimal integer (optional
-, digits, no leading zeros) that also falls inside whatTemporal.Instantcan represent. Shape alone isnanosecondDecimalinregex/. - Length is checked before
BigInt, so an arbitrarily long payload string is rejected rather than converted. - Takes the string value, not JSON text —
JSON.parse(payload).observedAt, not the payload. A quoted"\"123\""is not a decimal integer. - Returns
falsefor non-strings.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | candidate decimal string form of a nanosecond timestamp |
Returns
Section titled “Returns”boolean indicating whether parseNanoseconds will parse it
Examples
Section titled “Examples”import { isValidNanoPattern } from "@northguild/gmt/precision/validate";
isValidNanoPattern("1710072000123456789") // true