<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 const decodeSync: <
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.
decodeSync: <function (type parameter) S in <S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"]S extends import SchemaSchema.type Schema.ConstraintDecoder = /*unresolved*/ anyConstraintDecoder<unknown>>(
schema: S extends Schema.ConstraintDecoder<unknown>schema: function (type parameter) S in <S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"]S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions
) => (input: S["Encoded"]input: function (type parameter) S in <S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"]S["Encoded"], options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions) => function (type parameter) S in <S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"]S["Type"] = function decodeUnknownSync<
S extends Schema.ConstraintDecoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => S["Type"]
Creates a synchronous decoder for unknown input.
When to use
Use to decode untrusted or dynamically typed input at a synchronous boundary
where invalid data 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.
decodeUnknownSync