parseNull
Parses a value that must be null. This parser uses the validateNull primitive validator to ensure that the input is exactly the literal null. No normalization is performed.
The parser never throws and never mutates input. It returns a structured ParseResult<null> describing success or failure.
Signature
function parseNull(
value: unknown,
field?: string
): ParseResult<null>
Behavior
- Accepted inputs:
null(the literal value).- Rejected inputs:
undefined.- Numbers, strings, and booleans.
- Objects, arrays, and functions.
- Symbols.
- Bigint values.
- These produce: "Value must be null"
Returns
A ParseResult<null> object:
ok: trueAndvalue: nullwhen parsing succeeds.ok: false, value: nullAnd a list of issues when parsing fails.
Examples
parseNull(null)
// { ok: true, value: null, issues: [] }
parseNull(undefined)
// { ok: false, value: null, issues: ["Value must be null"] }
Notes
- This parser is intentionally strict: only the literal null is accepted.