<S extends Schema.ConstraintEncoder<unknown>>(
schema: S,
options?: SchemaAST.ParseOptions
): (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"]Creates a synchronous encoder for input already typed as the schema's decoded
Type.
When to use
Use to encode already typed schema values synchronously when encoding failure
should 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.
export const const encodeSync: <
S extends Schema.ConstraintEncoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
) => (
input: S["Type"],
options?: SchemaAST.ParseOptions
) => S["Encoded"]
Creates a synchronous encoder for input already typed as the schema's decoded
Type.
When to use
Use to encode already typed schema values synchronously when encoding failure
should 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.
encodeSync: <function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"]S extends import SchemaSchema.type Schema.ConstraintEncoder = /*unresolved*/ anyConstraintEncoder<unknown>>(
schema: S extends Schema.ConstraintEncoder<unknown>schema: function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"]S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions
) => (input: S["Type"]input: function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"]S["Type"], options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions) => function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"]S["Encoded"] = function encodeUnknownSync<
S extends Schema.ConstraintEncoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => S["Encoded"]
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.
encodeUnknownSync