<S extends Schema.ConstraintEncoder<unknown>>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Promise<S["Encoded"]>Creates a Promise-based encoder for unknown input.
When to use
Use when you need to encode untrusted or dynamically typed values with a
service-free schema and return a JavaScript Promise.
Details
The returned function resolves with the schema's Encoded value on success and
rejects with an Error whose cause is a SchemaIssue.Issue on encoding failure.
Gotchas
Causes that contain defects, interruptions, or other non-schema reasons reject
with an Error whose cause is the underlying Cause.
export const const encodeUnknownPromise: <
S extends Schema.ConstraintEncoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
) => (
input: unknown,
options?: SchemaAST.ParseOptions
) => Promise<S["Encoded"]>
Creates a Promise-based encoder for unknown input.
When to use
Use when you need to encode untrusted or dynamically typed values with a
service-free schema and return a JavaScript Promise.
Details
The returned function resolves with the schema's Encoded value on success and
rejects with an Error whose cause is a SchemaIssue.Issue on encoding failure.
Gotchas
Causes that contain defects, interruptions, or other non-schema reasons reject
with an Error whose cause is the underlying Cause.
encodeUnknownPromise = <function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<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: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]>S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.type SchemaAST.ParseOptions = /*unresolved*/ anyParseOptions
): (input: unknowninput: unknown, 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 <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]>S["Encoded"]> =>
function asPromise<T, E>(
parser: (
input: E,
options?: SchemaAST.ParseOptions
) => Effect.Effect<T, SchemaIssue.Issue>
): (
input: E,
options?: SchemaAST.ParseOptions
) => Promise<T>
asPromise(function encodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Encoded"],
SchemaIssue.Issue,
S["EncodingServices"]
>
Creates an effectful encoder for unknown input.
When to use
Use when you need to encode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving service
requirements.
Details
The returned function succeeds with the schema's Encoded value or fails with a
SchemaIssue.Issue. Encoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the encoder and overridden
when applying it.
encodeUnknownEffect(schema: S extends Schema.ConstraintEncoder<unknown>schema, options: SchemaAST.ParseOptionsoptions))