Skip to content

parseUndefined

Parses a value that must be undefined. This parser uses the validateUndefined primitive validator to ensure that the input is exactly the literal undefined. No normalization is performed.

The parser never throws and never mutates input. It returns a structured ParseResult<undefined> describing success or failure.

Signature

function parseUndefined(
    value: unknown,
    field?: string
): ParseResult<undefined>

Behavior

  • Accepted inputs:
  • undefined (the literal value)
  • Rejected inputs:
  • null.
  • Numbers, strings, and booleans.
  • Objects, arrays, and functions.
  • Symbols.
  • Bigint values.
  • These produce: "Value must be undefined"

Returns

  • ok: true and value Undefined when parsing succeeds.
  • ok: false, value: null And a list of issues when parsing fails.

Examples

parseUndefined(undefined)
// { ok: true, value: undefined, issues: [] }

parseUndefined(null)
// { ok: false, value: null, issues: ["Value must be undefined"] }

Notes

  • This parser is intentionally strict: only the literal undefined is accepted.