safeParseSequence
Parses a JSON text sequence (RFC 7464) like parseSequence, but returns null (or
fallback) instead of throwing on invalid input.
Accepts / rejects: exactly what parseSequence does, with the same ParseSequenceOptions.
On invalid input: returns fallback when one is given — even undefined, which is told
apart from an omitted argument — and null otherwise. Never throws. To pass options without
a fallback, pass null as the fallback.
Available since v3.1.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The JSON text sequence |
Returns
Section titled “Returns”T[] | null — The parsed values typed as T[], or null on invalid input (pass a fallback to get it instead)
Examples
Section titled “Examples”Read a sequence without throwing
Section titled “Read a sequence without throwing”Returns null if any record is invalid.
Provide a fallback
Section titled “Provide a fallback”The fallback is returned on invalid input.
Related Types
Section titled “Related Types”ParseSequenceOptions
Section titled “ParseSequenceOptions”Options for parseSequence and safeParseSequence.
