Hyperlinkv0.8.0-beta.28

SchemaParser

SchemaParser.encodeEffectconsteffect/SchemaParser.ts:631
<S extends Schema.Constraint>(
  schema: S,
  options?: SchemaAST.ParseOptions
): (
  input: S["Type"],
  options?: SchemaAST.ParseOptions
) => Effect.Effect<S["Encoded"], SchemaIssue.Issue, S["EncodingServices"]>

Creates an effectful encoder for input already typed as the schema's decoded Type.

When to use

Use when you need to encode values already typed as the schema's decoded Type in an Effect whose failure channel is SchemaIssue.Issue, while preserving service requirements.

Details

The returned function succeeds with the schema's Encoded value or fails with a SchemaIssue.Issue, preserving any encoding service requirements in the returned Effect.

export const encodeEffect: <S extends Schema.Constraint>(
  schema: S,
  options?: SchemaAST.ParseOptions
) => (
  input: S["Type"],
  options?: SchemaAST.ParseOptions
) => Effect.Effect<S["Encoded"], SchemaIssue.Issue, S["EncodingServices"]> = encodeUnknownEffect