You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
691 B
JavaScript
31 lines
691 B
JavaScript
5 years ago
|
"use strict";
|
||
|
|
||
|
const annotateErrors = require("./");
|
||
|
const ValidationError = require("@validatem/error");
|
||
|
|
||
|
let errors = [
|
||
|
new ValidationError("Error A"),
|
||
|
new ValidationError("Error B", { path: [ "somewhere" ] }),
|
||
|
];
|
||
|
|
||
|
annotateErrors({
|
||
|
errors: errors,
|
||
|
pathSegments: ["some", "path"]
|
||
|
});
|
||
|
|
||
|
console.log(errors);
|
||
|
/*
|
||
|
[ { ValidationError: Error A
|
||
|
<stacktrace>
|
||
|
path: [ 'some', 'path' ],
|
||
|
___validatem_isValidationError: true,
|
||
|
___validatem_errorVersion: 1,
|
||
|
message: 'Error A' },
|
||
|
{ ValidationError: Error B
|
||
|
<stacktrace>
|
||
|
path: [ 'some', 'path', 'somewhere' ],
|
||
|
___validatem_isValidationError: true,
|
||
|
___validatem_errorVersion: 1,
|
||
|
message: 'Error B' } ]
|
||
|
*/
|