Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Optional

Class representing Optional specs, which either accepts an undefined value or requires that the value satisfy the spec if present. Typically used with keys to denote specs for optional keys.

Hierarchy

Constructors

Properties

Methods

Constructors

constructor

  • new Optional(name: string, options: any): Optional

Properties

name

name: string

options

options: any

Methods

assert

  • assert(value: any): any
  • Asserts this spec on a given value. Returns the value if value passes spec, returns perusal-immutable.invalid otherwise.

    Parameters

    • value: any

      The value to be asserted.

    Returns any

    Returns the value if value passes spec, returns perusal-immutable.invalid otherwise.

explain

  • explain(value: any, path: string[]): boolean
  • Explains why a value passes/fails this spec.

    Parameters

    • value: any

      The value to be checked.

    • path: string[]

      The path travelled to this spec.

    Returns boolean

    Returns true if the value satisfies this spec, false otherwise.

Generated using TypeDoc