Hyperlinkv0.8.0-beta.28

SchemaParser

SchemaParser.decodeSyncconsteffect/SchemaParser.ts:571
<S extends Schema.ConstraintDecoder<unknown>>(
  schema: S,
  options?: SchemaAST.ParseOptions
): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"]

Creates a synchronous decoder for input already typed as the schema's Encoded type.

When to use

Use to decode values already typed as the schema's Encoded input when decoding failure should throw an Error whose cause is SchemaIssue.Issue.

Details

The returned function returns the decoded Type on success and throws an Error with the SchemaIssue.Issue in its cause on decoding 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.

export const decodeSync: <S extends Schema.ConstraintDecoder<unknown>>(
  schema: S,
  options?: SchemaAST.ParseOptions
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"] = decodeUnknownSync
Referenced by 2 symbols