isValidInstant
Signature
Section titled “Signature”isValidInstant(value: string): booleanisValidInstant(value: void | {} | null | undefined): booleanisValidInstant(value: unknown): value is stringValidate whether a string is an ISO 8601 instant string the precision/ namespace accepts.
- The predicate
toNanosecondswas missing.toNanosecondsreturns0nfor both the epoch and a rejected string, and the only public validator close enough to reach for —isValidUtc— is narrower than this grammar: it gates on GMT’s stricter<date>T<time>Zshape and rejects the offsetstoNanosecondsparses. Validating with it discards valid input. This accepts exactly whattoNanosecondsdoes, so the two never disagree. - Requires an offset designator (
Z,±HH:MM[:SS[.fraction]]) and nothing after it: an annotation of any kind (a time zone, a calendar, an elective one) returnsfalse. The offset alone fixes the instant, and an offset written with seconds is read exactly, so-00:44:30and-00:45are different instants. - ISO 8601 extended format over the whole string:
<date>T<time>, thenZor±HH:MM[:SS[.fraction]]. Basic format, a space or lower-casetseparator, a lower-casezand an hour-only time or offset returnfalse, althoughTemporal.Instant.fromreads them. - Rejects leap seconds in every separator and format variant.
- An empty string returns
false. - A value that is not a string, a
Stringobject included, returnsfalse. Atrueresult narrows anunknownvalue tostring.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | any value; a string is checked as an ISO 8601 instant string |
Returns
Section titled “Returns”boolean indicating whether toNanoseconds will parse it
Examples
Section titled “Examples”import { isValidInstant } from "@northguild/gmt/precision/validate";
isValidInstant("2024-03-10T12:00:00Z") // trueSource
Section titled “Source”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.