Skip to content

isValidNanoPattern

  • The core functions, which every industry uses.
isValidNanoPattern(value: string): boolean
isValidNanoPattern(value: void | {} | null | undefined): boolean
isValidNanoPattern(value: unknown): value is string

Validate whether a string is a nanosecond timestamp parseNanoseconds will parse.

  • parseNanoseconds returns 0n for 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 what Temporal.Instant can represent. Shape alone is nanosecondDecimal in regex/.
  • 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.
  • A value that is not a string, a String object included, returns false. A true result narrows an unknown value to string.
ParameterTypeDescription
valuestringany value; a string is checked as the decimal string form of a nanosecond timestamp

boolean indicating whether parseNanoseconds will parse it

import { isValidNanoPattern } from "@northguild/gmt/precision/validate";
isValidNanoPattern("1710072000123456789") // true
output 

precision/validate/isValidNanoPattern.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.