Package: effect
Module: SchemaParser
Creates a synchronous encoder for unknown input.
When to use
Use when you need to encode values from untyped input in synchronous code and
want encoding failures to throw an Error whose cause is SchemaIssue.Issue.
Details
The returned function returns the schema’s Encoded value on success and throws
an Error with the SchemaIssue.Issue in its cause on encoding failure.
Gotchas
Causes that contain defects, interruptions, or asynchronous work at this
synchronous boundary throw an Error whose cause is the underlying Cause,
instead of being converted to a schema validation error.
See
encodeSync for input already typed as the schema’s decoded TypeencodeUnknownEffect for effectful encoding that preserves service requirementsSignature
declare const encodeUnknownSync: <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: unknown, options?: SchemaAST.ParseOptions) => S["Encoded"]
Since v3.10.0