<S extends Schema.ConstraintDecoder<unknown>>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: S["Encoded"],
options?: SchemaAST.ParseOptions
) => Promise<S["Type"]>Creates a Promise-based decoder for input already typed as the schema's
Encoded type.
When to use
Use when you already have input typed as the schema's Encoded type and need
decoding to 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 decodePromise<
S extends Schema.ConstraintDecoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: S["Encoded"],
options?: SchemaAST.ParseOptions
) => Promise<S["Type"]>
Creates a Promise-based decoder for input already typed as the schema's
Encoded type.
When to use
Use when you already have input typed as the schema's Encoded type and need
decoding to 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.
decodePromise<function (type parameter) S in decodePromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S extends import SchemaSchema.type Schema.ConstraintDecoder = /*unresolved*/ anyConstraintDecoder<unknown>>(
schema: S extends Schema.ConstraintDecoder<unknown>schema: function (type parameter) S in decodePromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions
): (input: S["Encoded"]input: function (type parameter) S in decodePromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S["Encoded"], options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions) => interface Promise<T>Represents the completion of an asynchronous operation
Promise<function (type parameter) S in decodePromise<S extends Schema.ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Encoded"], 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(const decodeEffect: <
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
) => (
input: S["Encoded"],
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for input already typed as the schema's Encoded
type.
When to use
Use when you already have input typed as the schema's Encoded type and
need an Effect whose failure channel is SchemaIssue.Issue, while
preserving decoding service requirements.
Details
The returned function succeeds with the decoded Type or fails with a
SchemaIssue.Issue, preserving any decoding service requirements in the
returned Effect.
decodeEffect(schema: S extends Schema.ConstraintDecoder<unknown>schema, options: SchemaAST.ParseOptionsoptions))
}