Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OneOf

Class representing OneOf specs, which checks if a given value is contained within user pre-defined values. === is used for comparison.

Hierarchy

Constructors

Properties

Methods

Constructors

constructor

  • new OneOf(name: string, options: any): OneOf
  • Parameters

    • name: string
    • options: any

    Returns OneOf

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