<S extends Schema.ConstraintDecoder<unknown>>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Promise<S["Type"]>Creates a Promise-based decoder for unknown input.
When to use
Use when you need to decode untyped input with a service-free schema and
return a JavaScript Promise.
Details
The returned function resolves with the decoded Type on success and rejects
with an Error whose cause is a SchemaIssue.Issue on decoding failure.
Gotchas
Causes that contain defects, interruptions, or other non-schema reasons reject
with an Error whose cause is the underlying Cause.
export function function decodeUnknownPromise<
S extends Schema.ConstraintDecoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Promise<S["Type"]>
Creates a Promise-based decoder for unknown input.
When to use
Use when you need to decode untyped input with a service-free schema and
return a JavaScript Promise.
Details
The returned function resolves with the decoded Type on success and rejects
with an Error whose cause is a SchemaIssue.Issue on decoding failure.
Gotchas
Causes that contain defects, interruptions, or other non-schema reasons reject
with an Error whose cause is the underlying Cause.
decodeUnknownPromise<function (type parameter) S in decodeUnknownPromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S extends import SchemaSchema.interface ConstraintDecoder<out T, out RD = never>Lightweight structural constraint for APIs that need decoder type views but
do not need the full schema protocol.
When to use
Use when you need to preserve a schema's decoded type and decoding services,
but the API does not constrain the encoded type, encoding services, or call
schema methods such as annotate, check, rebuild, make, or
makeEffect.
ConstraintDecoder<unknown>>(
schema: S extends Schema.ConstraintDecoder<unknown>schema: function (type parameter) S in decodeUnknownPromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.ParseOptions
): (input: unknowninput: unknown, options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.ParseOptions) => interface Promise<T>Represents the completion of an asynchronous operation
Promise<function (type parameter) S in decodeUnknownPromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S["Type"]> {
return function asPromise<T, E>(
parser: (
input: E,
options?: SchemaAST.ParseOptions
) => Effect.Effect<T, SchemaIssue.Issue>
): (
input: E,
options?: SchemaAST.ParseOptions
) => Promise<T>
asPromise(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))
}