Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DuckMismatchInfo

Inherits MismatchInfo and only overrides toErrorString() method.

Hierarchy

Implements

Index

Constructors

constructor

Properties

actualValue

actualValue: unknown

Value that failed to conform to the expectedTd.

expectedTd

expectedTd: TypeDescription

TypeDescription that actualValue was expected to conform to.

path

path: PathArray

An array of numbers and strings which defines a path to suspect's invalid actualValue. @remarks E.g. if suspect.foo.bar[3][5] failed to match to the expectedTd, then path would be [ 'foo', 'bar', 3, 5 ].

Methods

pathString

  • pathString(): string | number
  • Returns path converted to a human readable JavaScript property access notation string if match was failed. Returned string begins with the 'root' as the root object to access the properties.

    remarks
    import * as Vts from 'vee-type-safe';
    const mismatchInfo = Vts.mismatch(
        {
            foo: {
                bar: {
                    'twenty two': [
                        { prop: 'str' },
                        { prop: -23 }
                    ]
                }
            }
        },
        { foo: { bar: { 'twenty two': [ { prop: 'string' } ] } } }
    );
    
    mismatchInfo.pathString() === `root.foo.bar['twenty two'][1].prop`;

    Returns string | number

toErrorString

  • toErrorString(): string

Generated using TypeDoc