Assert overview

Added in v2.2.0


Table of contents


Interpreters

deriveAssert

A trait which will throw an error for when an expected “output” value does not match a schema’s output type

Signature

export declare const deriveAssert: <I, O>(schema: Schema<I, O>) => Assert<O>

Added in v2.2.0

deriveInputAssert

A trait which will throw an error for when an expected “input” value does not match a schema’s input type

Signature

export declare const deriveInputAssert: <I, O>(schema: Schema<I, O>) => Assert<I>

Added in v2.2.0

deriveInputAssertTree

A trait which will throw an error for when an expected “input” value does not match a schema’s input type

Unlike deriveInputAssert, this will include the error tree in the error message

Signature

export declare const deriveInputAssertTree: <I, O>(schema: Schema<I, O>) => Assert<I>

Added in v2.2.0

Models

Assert (interface)

A trait which will throw an error for when a value does not match a schema

Signature

export interface Assert<T> {
  readonly assert: (output: unknown) => asserts output is T
}

Added in v2.2.0