« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/validators.js13
-rw-r--r--src/data/yaml.js12
2 files changed, 12 insertions, 13 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');
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 18f67c74..47cdc858 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -474,18 +474,6 @@ export function parseAdditionalFiles(array) {
   }));
 }
 
-export function parseCommentary(text) {
-  if (text) {
-    const lines = String(text.trim()).split('\n');
-    if (!lines[0].replace(/<\/b>/g, '').includes(':</i>')) {
-      throw new Error(`Missing commentary citation: "${lines[0].slice(0, 40)}..."`);
-    }
-    return text;
-  } else {
-    return null;
-  }
-}
-
 export function parseContributors(contributors) {
   if (!contributors) {
     return null;