« get me outta code hell

data format cleanup: commentary fields - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-02-05 08:40:25 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-02-05 08:40:25 -0400
commitf554897f3728fcb771fe26dffad898a54b37335a (patch)
tree993f747c1cc8d159b0e8072a2a20206c656d4c13 /src/data/things
parentbbb9a3ad9c4626b4b9a2559d0e251d1fe1f5ef01 (diff)
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.
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/validators.js13
1 files changed, 12 insertions, 1 deletions
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(':</i>')) {
+    throw new TypeError(`Missing commentary citation: "${
+      firstLine.length > 40
+        ? firstLine.slice(0, 40) + '...'
+        : firstLine
+    }"`);
+  }
+
+  return true;
 }
 
 const isArtistRef = validateReference('artist');