effect-io-ai

Package: effect
Module: SchemaGetter

SchemaGetter.onNone

Creates a getter that handles the case when the input is absent (Option.None).

When to use

Use when you need a schema getter to provide a fallback or computed value for missing struct keys.

Details

Example (Providing a default timestamp for a missing field)

import { Effect, Option, SchemaGetter } from "effect"

const withTimestamp = SchemaGetter.onNone<number>(() =>
  Effect.succeed(Option.some(Date.now()))
)

See

Signature

declare const onNone: <T, E extends T = T, R = never>(f: (options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>) => Getter<T, E, R>

Source

Since v4.0.0