Hyperlinkv0.8.0-beta.28

SchemaParser

SchemaParser.isfunctioneffect/SchemaParser.ts:173
<S extends Schema.Constraint>(schema: S): <I>(
  input: I
) => input is I & S["Type"]

Creates a type guard that checks whether an input satisfies the schema's decoded type side.

When to use

Use to build a type guard for checking the decoded side of a schema without exposing issue details.

Details

The guard returns true on successful validation and false when validation fails only with schema issues, without exposing issue details.

Gotchas

Only causes made entirely of schema issues are converted to false. Causes that contain defects, interruptions, or asynchronous work at this synchronous boundary throw an Error whose cause is the underlying Cause.

Asserting
export function is<S extends Schema.Constraint>(schema: S): <I>(input: I) => input is I & S["Type"] {
  return _is<S["Type"]>(schema.ast)
}
Referenced by 1 symbols