<S extends ConstraintDecoder<unknown>>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Promise<S["Type"]>Decodes an unknown input against a schema, returning a Promise that
resolves with the decoded value or rejects with a SchemaError for
schema mismatches.
When to use
Use when you need decoding of unknown input to return a JavaScript Promise
that rejects with SchemaError for schema mismatches.
Details
For input already typed as the schema's Encoded type use
decodePromise.
Options may be provided either when creating the decoder or when applying it;
application options override creation options.
Gotchas
Non-schema failures may reject with a runtime failure instead of
SchemaError.
export function function decodeUnknownPromise<
S extends ConstraintDecoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Promise<S["Type"]>
Decodes an unknown input against a schema, returning a Promise that
resolves with the decoded value or rejects with a
SchemaError
for
schema mismatches.
When to use
Use when you need decoding of unknown input to return a JavaScript Promise
that rejects with SchemaError for schema mismatches.
Details
For input already typed as the schema's Encoded type use
decodePromise
.
Options may be provided either when creating the decoder or when applying it;
application options override creation options.
Gotchas
Non-schema failures may reject with a runtime failure instead of
SchemaError.
decodeUnknownPromise<function (type parameter) S in decodeUnknownPromise<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S extends 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 ConstraintDecoder<unknown>schema: function (type parameter) S in decodeUnknownPromise<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.ParseOptions
) {
const const parser: (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaError,
S["DecodingServices"]
>
parser = function decodeUnknownEffect<
S extends Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaError,
S["DecodingServices"]
>
Decodes an unknown input against a schema, returning an Effect that
succeeds with the decoded value or fails with a
SchemaError
.
When to use
Use when you need to decode unknown input in an Effect whose failure
channel is SchemaError.
Details
Prefer
decodeEffect
when the input is already typed as the schema's
Encoded type.
Options may be provided either when creating the decoder or when applying it;
application options override creation options.
decodeUnknownEffect(schema: S extends ConstraintDecoder<unknown>schema, options: SchemaAST.ParseOptionsoptions)
return (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 ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>S["Type"]> => {
return function runSchemaErrorPromise<A>(
self: Effect.Effect<A, SchemaError>
): Promise<A>
runSchemaErrorPromise(const parser: (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaError,
S["DecodingServices"]
>
parser(input: unknowninput, options: SchemaAST.ParseOptionsoptions))
}
}