effect-io-ai

Package: effect
Module: SchemaParser

SchemaParser.encodeUnknownResult

Creates an encoder for unknown input that reports failure safely as a Result.

When to use

Use when encoding values from an unknown or dynamically typed boundary synchronously, and you want SchemaIssue.Issue failures returned as Result data.

Details

The returned function produces Result.succeed with the schema’s Encoded value on success or Result.fail with a SchemaIssue.Issue on encoding failure.

Gotchas

This adapter runs synchronously. Causes made entirely of schema issues become Result.fail, but causes that contain defects, interruptions, or asynchronous work at this synchronous boundary throw instead.

See

Signature

declare const encodeUnknownResult: <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: unknown, options?: SchemaAST.ParseOptions) => Result.Result<S["Encoded"], SchemaIssue.Issue>

Source

Since v4.0.0