Skip to content

ok

Creates a successful ParseResult<T> containing the provided value. This helper is the canonical way to construct success results in safe parsers, validators, and other result-producing helpers.

It never throws and never mutates input.

Signature

function ok<T>(value: T): ParseResult<T>

Parameters

Returns

A ParseResult<T> with:

  • ok: true, value: T, issues: []

Behavior

  • Always returns a success result.
  • Never throws.
  • Never mutates input.
  • Ensures issues is always an empty array.
  • Ensures value is preserved exactly as provided.

Examples

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

ok("hello")
// { ok: true, value: "hello", issues: [] }

ok({ a: 1 })
// { ok: true, value: { a: 1 }, issues: [] }

Notes

  • ok is the preferred way to construct success results across the Jane ecosystem.
  • It ensures consistent structure and predictable behavior in all result-based workflows.