The failure that triggered this error or an error message
Optional
Rest
...params: any[]Additional Error constructor parameters
Private
#failureThe root validation failure that triggered this error.
Retrieve the root failure that caused this error, or a specific sub-failure via a path.
Optional
path: stringThe property path to the 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"
}
Retrieve a flattened object of all the properties that failed validation as part of this error.
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));
}
}
Static
Private
#aggregateCollect nested failures into an aggregate object.
The failure.
Returns the failure at the leaf of the tree, otherwise an object of sub-failures.
A specialised Error to indicate a model validation failure.