Convert any JSON-shaped value to a display string suitable for
form input attributes or text rendering.
Centralises the conversion logic because EnumField.enumValues and
LiteralField.literalValues are typed as unknown[] (Draft 2020-12
permits any JSON value in enum / const). Renderers call this
helper instead of inlining their own narrowing — the alternative
String(v) on unknown trips @typescript-eslint/no-base-to-string.
Inputs originate from parsed JSON (or runtime JSON-equivalents) so
they are always null | boolean | number | string | object | array.
Objects and arrays serialise via JSON.stringify so a discriminated
union with object const values still produces a stable display key.
Throws on non-JSON-shaped values (function, symbol, bigint, undefined)
— their presence indicates the producer violated the JSON contract.
Convert any JSON-shaped value to a display string suitable for form input attributes or text rendering.
Centralises the conversion logic because
EnumField.enumValuesandLiteralField.literalValuesare typed asunknown[](Draft 2020-12 permits any JSON value inenum/const). Renderers call this helper instead of inlining their own narrowing — the alternativeString(v)onunknowntrips@typescript-eslint/no-base-to-string.Inputs originate from parsed JSON (or runtime JSON-equivalents) so they are always
null | boolean | number | string | object | array. Objects and arrays serialise viaJSON.stringifyso a discriminated union with object const values still produces a stable display key.Throws on non-JSON-shaped values (function, symbol, bigint, undefined) — their presence indicates the producer violated the JSON contract.