MCPcopy Create free account
hub / github.com/effect-app/libs / decodeTo

Function decodeTo

repos/effect/packages/effect/src/Schema.ts:5410–5430  ·  view source on GitHub ↗
(
  to: To,
  transformation?: {
    readonly decode: SchemaGetter.Getter<To["Encoded"], From["Type"], RD>
    readonly encode: SchemaGetter.Getter<From["Type"], To["Encoded"], RE>
  } | undefined
)

Source from the content-addressed store, hash-verified

5408 * with a fallback value or re-fails with a (possibly different) issue. The
5409 * handler's services are added to the schema's decoding services.
5410 *
5411 * @see {@link catchDecoding} for recovery handlers that do not require services
5412 * @see {@link middlewareDecoding} for intercepting or replacing the full decoding pipeline
5413 *
5414 * @category error handling
5415 * @since 4.0.0
5416 */
5417export function catchDecodingWithContext<S extends Constraint, R = never>(
5418 f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>
5419) {
5420 return (self: S): middlewareDecoding<S, S["DecodingServices"] | R> =>
5421 middlewareDecoding<S, S["DecodingServices"] | R>(Effect.catchEager(f))(self)
5422}
5423
5424/**
5425 * Recovers from an encoding error by providing a fallback value.
5426 *
5427 * **Details**
5428 *
5429 * The handler receives the `Issue` and returns an `Effect` that either
5430 * succeeds with a fallback value or re-fails with a (possibly different) issue.
5431 *
5432 * @see {@link catchEncodingWithContext} to add service requirements to the handler
5433 * @category error handling

Callers 15

transformFunction · 0.70
encodeKeysFunction · 0.70
extendToFunction · 0.70
ArrayEnsureFunction · 0.70
decodeFunction · 0.70
encodeToFunction · 0.70
encodeFunction · 0.70
withDecodingDefaultKeyFunction · 0.70
withDecodingDefaultFunction · 0.70
OptionFromNullOrFunction · 0.70
OptionFromUndefinedOrFunction · 0.70
OptionFromNullishOrFunction · 0.70

Calls 2

makeFunction · 0.70
makeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…