effect-io-ai

Package: effect
Module: Schema

Schema.encodeSync

Encodes a typed input (the schema’s Type) against a schema synchronously, throwing a SchemaError for schema mismatches.

When to use

Use when you already have a value typed as the schema’s Type and want schema mismatches to throw SchemaError synchronously.

Details

For unknown input use encodeUnknownSync. Options may be provided either when creating the encoder or when applying it; application options override creation options.

Gotchas

Non-schema failures may throw a runtime failure instead of SchemaError.

See

Signature

declare const encodeSync: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"]

Source

Since v4.0.0