Package: effect
Module: SchemaGetter
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.
withDefault.Details
None, calls f to produce the result.Some, passes it through unchanged.f receives the parse options and may return None to keep the value absent.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
required when absent input should failwithDefault for a simpler default value for undefined inputsonSome to handle only present valuesSignature
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>
Since v4.0.0