Hyperlinkv0.8.0-beta.28

SchemaParser

SchemaParser.decodeUnknownResultfunctioneffect/SchemaParser.ts:472
<S extends Schema.ConstraintDecoder<unknown>>(
  schema: S,
  options?: SchemaAST.ParseOptions
): (
  input: unknown,
  options?: SchemaAST.ParseOptions
) => Result.Result<S["Type"], SchemaIssue.Issue>

Creates a decoder for unknown input that reports failure safely as a Result.

When to use

Use when decoding untyped boundary input and you want SchemaIssue.Issue failures returned as data in a Result.

Details

The returned function produces Result.succeed with the decoded Type on success or Result.fail with a SchemaIssue.Issue on decoding failure.

Gotchas

This adapter runs synchronously. Causes made entirely of schema issues become Result.fail, but causes that contain defects, interruptions, or asynchronous work at this synchronous boundary throw instead.

export function decodeUnknownResult<S extends Schema.ConstraintDecoder<unknown>>(
  schema: S,
  options?: SchemaAST.ParseOptions
): (input: unknown, options?: SchemaAST.ParseOptions) => Result.Result<S["Type"], SchemaIssue.Issue> {
  return asResult(decodeUnknownEffect(schema, options))
}
Referenced by 2 symbols