Options
All
  • Public
  • Public/Protected
  • All
Menu

A specialised Error to indicate a model validation failure.

Hierarchy

  • Error
    • DataModelValidationError

Index

Constructors

Methods

  • Retrieve the root failure that caused this error, or a specific sub-failure via a path.

    example

    Retrieving a failure.

    const changes = {
    "foo.bar": "validValue",
    "foo.baz": "invalidValue"
    };
    try {
    doc.validate(expandObject(changes));
    } catch ( err ) {
    const failure = err.getFailure("foo.baz");
    console.log(failure.invalidValue); // "invalidValue"
    }

    Parameters

    • path: string

    Returns DataModelValidationFailure

  • getAllFailures(): any
  • Retrieve a flattened object of all the properties that failed validation as part of this error.

    example

    Removing invalid changes from an update delta.

    const changes = {
    "foo.bar": "validValue",
    "foo.baz": "invalidValue"
    };
    try {
    doc.validate(expandObject(changes));
    } catch ( err ) {
    const failures = err.getAllFailures();
    if ( failures ) {
    for ( const prop in failures ) delete changes[prop];
    doc.validate(expandObject(changes));
    }
    }

    Returns any

  • logAsTable(): void
  • Log the validation error as a table.

    Returns void

  • asHTML(): string
  • Generate a nested tree view of the error as an HTML string.

    Returns string

  • Collect nested failures into an aggregate object.

    Parameters

    Returns any

    Returns the failure at the leaf of the tree, otherwise an object of sub-failures.

Properties

The root validation failure that triggered this error.