Package: effect
Module: Schema
Encodes an unknown input against a schema synchronously, throwing a
SchemaError for schema mismatches.
When to use
Use when you need to serialize unknown data at a synchronous boundary and
want schema mismatches to throw SchemaError.
Details
For alternatives that do not throw on schema mismatches, see
encodeUnknownOption, encodeUnknownExit, or
encodeUnknownEffect. For values already typed as the schema’s Type
use encodeSync. 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
SchemaParser.encodeUnknownSync for the adapter that throws an Error whose cause is SchemaIssue.IssueSignature
declare const encodeUnknownSync: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: unknown, options?: SchemaAST.ParseOptions) => S["Encoded"]
Since v4.0.0