MCPcopy Create free account
hub / github.com/Effect-TS/effect / withConstructorDefault

Function withConstructorDefault

packages/effect/src/SchemaAST.ts:3546–3559  ·  view source on GitHub ↗
(
  ast: A,
  defaultValue: Effect.Effect<unknown, SchemaIssue.Issue>
)

Source from the content-addressed store, hash-verified

3544
3545/** @internal */
3546export function withConstructorDefault<A extends AST>(
3547 ast: A,
3548 defaultValue: Effect.Effect<unknown, SchemaIssue.Issue>
3549): A {
3550 const transformation = new SchemaTransformation.Transformation(
3551 SchemaGetter.withDefault(defaultValue),
3552 SchemaGetter.passthrough()
3553 )
3554 const constructorDefault = new Link(unknown, transformation)
3555 const context = ast.context ?
3556 new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) :
3557 new Context(false, false, constructorDefault)
3558 return replaceContext(ast, context)
3559}
3560
3561/**
3562 * Attaches a `Transformation` to the `to` AST, making it decode from the

Callers

nothing calls this directly

Calls 1

replaceContextFunction · 0.85

Tested by

no test coverage detected