diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-05-22 17:56:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-22 17:56:44 -0400 |
commit | d7cf019b4a8266e8022d82d8d5433c4605921a98 (patch) | |
tree | b77e49eb7a4ea4db5f1184e8df316cd75ed6ef8a /ext/js/language | |
parent | d16739a83a20e1729e08dbcbbc155be15972d146 (diff) |
Json schema improvements (#1698)
* Simplify schema multi-push/pop
* Reverse order of schema path
* Reverse order of value path
* Simplify schema path structure
* Rename for better clarity
Diffstat (limited to 'ext/js/language')
-rw-r--r-- | ext/js/language/dictionary-importer.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index 9365683b..a0806a3a 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -253,8 +253,8 @@ class DictionaryImporter { } _formatSchemaError(e, fileName) { - const valuePathString = this._getSchemaErrorPathString(e.valuePath, 'dictionary'); - const schemaPathString = this._getSchemaErrorPathString(e.schemaPath, 'schema'); + const valuePathString = this._getSchemaErrorPathString(e.valueStack, 'dictionary'); + const schemaPathString = this._getSchemaErrorPathString(e.schemaStack, 'schema'); const e2 = new Error(`Dictionary has invalid data in '${fileName}' for value '${valuePathString}', validated against '${schemaPathString}': ${e.message}`); e2.data = e; @@ -265,16 +265,23 @@ class DictionaryImporter { _getSchemaErrorPathString(infoList, base='') { let result = base; for (const {path} of infoList) { - switch (typeof path) { - case 'string': - if (result.length > 0) { - result += '.'; + const pathArray = Array.isArray(path) ? path : [path]; + for (const pathPart of pathArray) { + if (pathPart === null) { + result = base; + } else { + switch (typeof pathPart) { + case 'string': + if (result.length > 0) { + result += '.'; + } + result += pathPart; + break; + case 'number': + result += `[${pathPart}]`; + break; } - result += path; - break; - case 'number': - result += `[${path}]`; - break; + } } } return result; |