|
|
@ -4,6 +4,7 @@ const indentString = require("indent-string");
|
|
|
|
const supportsColor = require("supports-color");
|
|
|
|
const supportsColor = require("supports-color");
|
|
|
|
const matchVirtualProperty = require("@validatem/match-virtual-property");
|
|
|
|
const matchVirtualProperty = require("@validatem/match-virtual-property");
|
|
|
|
const asExpression = require("as-expression");
|
|
|
|
const asExpression = require("as-expression");
|
|
|
|
|
|
|
|
const syncpipe = require("syncpipe");
|
|
|
|
|
|
|
|
|
|
|
|
const AggregrateValidationError = require("./aggregrate-validation-error");
|
|
|
|
const AggregrateValidationError = require("./aggregrate-validation-error");
|
|
|
|
|
|
|
|
|
|
|
@ -54,7 +55,7 @@ function renderErrorList(errors, subErrorLevels = 0) {
|
|
|
|
? `${lineCharacter} ${joinPathSegments(pathSegments)}: ${error.message}`
|
|
|
|
? `${lineCharacter} ${joinPathSegments(pathSegments)}: ${error.message}`
|
|
|
|
: `${lineCharacter} ${error.message}`;
|
|
|
|
: `${lineCharacter} ${error.message}`;
|
|
|
|
|
|
|
|
|
|
|
|
return indentString(message, subErrorLevels * 4);
|
|
|
|
return message;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return (pathSegments.length > 0)
|
|
|
|
return (pathSegments.length > 0)
|
|
|
|
? ` - At ${joinPathSegments(pathSegments)}: ${error.message}`
|
|
|
|
? ` - At ${joinPathSegments(pathSegments)}: ${error.message}`
|
|
|
@ -64,8 +65,17 @@ function renderErrorList(errors, subErrorLevels = 0) {
|
|
|
|
|
|
|
|
|
|
|
|
if (error.subErrors != null && error.subErrors.length > 0) {
|
|
|
|
if (error.subErrors != null && error.subErrors.length > 0) {
|
|
|
|
let renderedSubErrors = renderErrorList(error.subErrors, subErrorLevels + 1);
|
|
|
|
let renderedSubErrors = renderErrorList(error.subErrors, subErrorLevels + 1);
|
|
|
|
|
|
|
|
let isLastError = (i === errors.length - 1);
|
|
|
|
|
|
|
|
|
|
|
|
return mainLine + "\n" + renderedSubErrors;
|
|
|
|
if (subErrorLevels > 0 && !isLastError) {
|
|
|
|
|
|
|
|
return syncpipe(renderedSubErrors, [
|
|
|
|
|
|
|
|
(_) => indentString(_, 3),
|
|
|
|
|
|
|
|
(_) => indentString(_, 1, { indent: "│" }),
|
|
|
|
|
|
|
|
(_) => mainLine + "\n" + _
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return mainLine + "\n" + indentString(renderedSubErrors, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return mainLine;
|
|
|
|
return mainLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|