Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FailedMatchInfo

deprecated

Use just class MismatchInfo

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

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 ].

Accessors

matched

  • get matched(): boolean

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
  • Returns a string of form: "value (JSON.stringify(actualValue)) at path 'pathString()' doesn't exactly conform to the given type description (stringifyTd(expectedTd))"

    remarks

    If JSON.stringify(actualValue) throws an error, it is excluded from the returned string.

    Returns string

Generated using TypeDoc