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

Function middlewareEncoding

packages/effect/src/Schema.ts:5374–5385  ·  view source on GitHub ↗
(
  encode: (
    effect: Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, S["EncodingServices"]>,
    options: SchemaAST.ParseOptions
  ) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, RE>
)

Source from the content-addressed store, hash-verified

5372 * @since 4.0.0
5373 */
5374export function middlewareEncoding<S extends Constraint, RE>(
5375 encode: (
5376 effect: Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, S["EncodingServices"]>,
5377 options: SchemaAST.ParseOptions
5378 ) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, RE>
5379) {
5380 return (schema: S): middlewareEncoding<S, RE> =>
5381 make(
5382 SchemaAST.middlewareEncoding(schema.ast, new SchemaTransformation.Middleware(identity, encode)),
5383 { schema }
5384 )
5385}
5386
5387/**
5388 * Recovers from a decoding error by providing a fallback value.

Callers 1

catchEncodingWithContextFunction · 0.70

Calls 1

makeFunction · 0.70

Tested by

no test coverage detected