From f554897f3728fcb771fe26dffad898a54b37335a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 5 Feb 2023 08:40:25 -0400 Subject: data format cleanup: commentary fields The parseCommentary function was actually going unused. This commit moves its behavior to the more appropriate location (validateCommentary), which actually unveils a couple data errors in the HSMusic data files. --- src/data/things/validators.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/data/things/validators.js') diff --git a/src/data/things/validators.js b/src/data/things/validators.js index 24db3c79..b116120a 100644 --- a/src/data/things/validators.js +++ b/src/data/things/validators.js @@ -195,7 +195,18 @@ export function isColor(color) { } export function isCommentary(commentary) { - return isString(commentary); + isString(commentary); + + const [firstLine] = commentary.match(/.*/); + if (!firstLine.replace(/<\/b>/g, '').includes(':')) { + throw new TypeError(`Missing commentary citation: "${ + firstLine.length > 40 + ? firstLine.slice(0, 40) + '...' + : firstLine + }"`); + } + + return true; } const isArtistRef = validateReference('artist'); -- cgit 1.3.0-6-gf8a5