Skip to content

Safe parsers

Safe parsers attempt to convert unknown input into a well‑defined type without ever throwing exceptions or mutating data. They return structured ParseResult<T> objects that make success and failure explicit, predictable, and easy to handle.

A safe parser never coerces values implicitly, never hides errors, and never surprises you. It either returns a clean, normalized value or a clear list of issues. This makes your workflows easier to reason about and safer to compose.

Safe parsers in Jane are pure, deterministic, and side‑effect‑free. They form the backbone of clarity‑first data handling.

Available safe parsers

Safe parsers are grouped by category for clarity and searchability:

Each category contains focused helpers that normalize input into predictable, well‑typed values.

When to use safe parsers

Use safe parsers when:

  • You need to normalize unknown input into a specific type.
  • You want to avoid exceptions, implicit coercion, and runtime surprises.
  • You want a structured result instead of boolean branching.
  • You need a predictable contract for downstream validation or domain logic.
  • You want workflows that are explicit, testable, and intention‑revealing.

Safe parsers are ideal when you want to transform input into a usable form while preserving full control over error handling.

Why safe parsers matter

Safe parsers give you:

  • Explicit success and failure paths: No guessing, no hidden coercion, no silent fallbacks.
  • Consistent return shapes: Every parser returns { ok, value, issues }, making pipelines uniform.
  • Predictable normalization: Values are only accepted when they meet strict, documented rules.
  • Zero side effects: No mutation, no throwing, no global state.
  • Composability: Parsers chain cleanly with validators, normalizers, and domain logic.

Safe parsers help you write workflows that are clear, defensive, and easy to maintain. They turn unknown input into well‑typed data without sacrificing safety or readability.