<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.
export function 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<function (type parameter) S in decodeUnknownSync<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, 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 decodeUnknownSync<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => S["Type"]S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions
): (input: unknowninput: unknown, options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions) => function (type parameter) S in decodeUnknownSync<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => S["Type"]S["Type"] {
return function asSync<T, E>(
parser: (
input: E,
options?: SchemaAST.ParseOptions
) => Effect.Effect<T, SchemaIssue.Issue>
): (
input: E,
options?: SchemaAST.ParseOptions
) => T
asSync(function decodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for unknown input.
When to use
Use when you need to decode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving transformations
and service requirements.
Details
The returned function succeeds with the schema's decoded Type or fails with a
SchemaIssue.Issue. Decoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the decoder and overridden
when applying it.
decodeUnknownEffect(schema: S extends Schema.ConstraintDecoder<unknown>schema, options: SchemaAST.ParseOptionsoptions))
}