Package: effect
Module: SchemaGetter
Creates a getter that replaces undefined values with a default.
When to use
Use when you need a schema getter to provide a fallback for a field that may
be undefined in the encoded input.
Details
Some(undefined) or None, produces Some(T).Some(value) where value is not undefined, passes it through.defaultValue is an Effect that will be executed each time a default is needed.Example (Providing a default value for an optional field)
import { Effect, SchemaGetter } from "effect"
const withZero = SchemaGetter.withDefault(Effect.succeed(0))
// Getter<number, number | undefined>
See
onNone to handle only absent keys (not undefined values)required when absent input should fail instead of using a defaultSignature
declare const withDefault: <T, R = never>(defaultValue: Effect.Effect<T, SchemaIssue.Issue, R>) => Getter<T, T | undefined, R>
Since v4.0.0