Guard overview

Guard is a data-type that narrows an unknown value to a specific type using Typescript type guards

Added in v2.0.0


Table of contents


Constructors

fromPredicate

Constructs a guard from predicate function

Signature

export declare const fromPredicate: <A>(predicate: (u: unknown) => u is A) => Guard<A>

Added in v2.0.0

Interpreters

deriveGuard

Interprets a schema as a guard for the Output type

Signature

export declare const deriveGuard: Interpreter<I.SchemableLambda>

Added in v2.0.0

deriveInputGuard

Interprets a schema as a guard for the Input type

Signature

export declare const deriveInputGuard: <I, O>(schema: Schema<I, O>) => Guard<I>

Added in v2.1.0

Model

Guard (interface)

Represents a typeclass and data-type that narrows an unknown value to a specific type

Signature

export interface Guard<A> {
  readonly is: (u: unknown) => u is A
}

Added in v2.0.0

URI

URI

Signature

export declare const URI: 'schemata-ts/Guard'

Added in v2.0.0

URI (type alias)

Signature

export type URI = typeof URI

Added in v2.0.0