Hyperlinkv0.8.0-beta.28

SchemaParser

SchemaParser.encodeUnknownPromiseconsteffect/SchemaParser.ts:663
<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 encodeUnknownPromise = <S extends Schema.ConstraintEncoder<unknown>>(
  schema: S,
  options?: SchemaAST.ParseOptions
): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]> =>
  asPromise(encodeUnknownEffect(schema, options))
Referenced by 1 symbols