Improve subError rendering
This commit is contained in:
parent
be5fd46005
commit
eba89ed9c5
|
@ -4,6 +4,7 @@ const indentString = require("indent-string");
|
|||
const supportsColor = require("supports-color");
|
||||
const matchVirtualProperty = require("@validatem/match-virtual-property");
|
||||
const asExpression = require("as-expression");
|
||||
const syncpipe = require("syncpipe");
|
||||
|
||||
const AggregrateValidationError = require("./aggregrate-validation-error");
|
||||
|
||||
|
@ -54,7 +55,7 @@ function renderErrorList(errors, subErrorLevels = 0) {
|
|||
? `${lineCharacter} ${joinPathSegments(pathSegments)}: ${error.message}`
|
||||
: `${lineCharacter} ${error.message}`;
|
||||
|
||||
return indentString(message, subErrorLevels * 4);
|
||||
return message;
|
||||
} else {
|
||||
return (pathSegments.length > 0)
|
||||
? ` - At ${joinPathSegments(pathSegments)}: ${error.message}`
|
||||
|
@ -64,8 +65,17 @@ function renderErrorList(errors, subErrorLevels = 0) {
|
|||
|
||||
if (error.subErrors != null && error.subErrors.length > 0) {
|
||||
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 {
|
||||
return mainLine;
|
||||
}
|
||||
|
|
|
@ -1148,6 +1148,13 @@ supports-color@^7.1.0:
|
|||
dependencies:
|
||||
has-flag "^4.0.0"
|
||||
|
||||
syncpipe@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/syncpipe/-/syncpipe-1.0.0.tgz#170340f813150bc8fcb8878b1b9c71ea0ccd3727"
|
||||
integrity sha512-cdiAFTnFJRvUaNPDc2n9CqoFvtIL3+JUMJZrC3kA3FzpugHOqu0TvkgNwmnxPZ5/WjAzMcfMS3xm+AO7rg/j/w==
|
||||
dependencies:
|
||||
assure-array "^1.0.0"
|
||||
|
||||
table@^5.2.3:
|
||||
version "5.4.6"
|
||||
resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
|
||||
|
|
Loading…
Reference in a new issue