diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-01-13 14:30:44 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-01-13 14:30:44 -0400 |
commit | ba94f5c02f867630604f94eb64138fe260c320c1 (patch) | |
tree | d31346e185510b2119f3da187fc00fb65d607e34 /src | |
parent | 4ae877bc6dcc89c3899b2e1c3d5febf9e28334d6 (diff) |
yaml: refactor custom last step in reference validation
Diffstat (limited to 'src')
-rw-r--r-- | src/data/yaml.js | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js index cdbd6954..9ee1d612 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -1902,23 +1902,31 @@ export function filterReferenceErrors(wikiData) { let newPropertyValue = value; - if (findFnKey === '_commentary') { - // Commentary doesn't write a property value, so no need to set. - filter( - value, {message: errorMessage}, - decorateErrorWithIndex(refs => - (refs.length === 1 - ? suppress(findFn)(refs[0]) - : filterAggregate( - refs, {message: `Errors in entry's artist references`}, - decorateErrorWithIndex(suppress(findFn))) - .aggregate - .close()))); - } else if (Array.isArray(value)) { - newPropertyValue = filter( - value, {message: errorMessage}, - decorateErrorWithIndex(suppress(findFn))); - } else { + determineNewPropertyValue: { + if (findFnKey === '_commentary') { + filter( + value, {message: errorMessage}, + decorateErrorWithIndex(refs => + (refs.length === 1 + ? suppress(findFn)(refs[0]) + : filterAggregate( + refs, {message: `Errors in entry's artist references`}, + decorateErrorWithIndex(suppress(findFn))) + .aggregate + .close()))); + + // Commentary doesn't write a property value, so no need to set + // anything on `newPropertyValue`. + break determineNewPropertyValue; + } + + if (Array.isArray(value)) { + newPropertyValue = filter( + value, {message: errorMessage}, + decorateErrorWithIndex(suppress(findFn))); + break determineNewPropertyValue; + } + nest({message: errorMessage}, suppress(({call}) => { try { |