« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/validators.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/validators.js')
-rw-r--r--src/validators.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/validators.js b/src/validators.js
index 9b34cc04..5300d4ad 100644
--- a/src/validators.js
+++ b/src/validators.js
@@ -368,9 +368,28 @@ export const isCommentary =
     caseSensitiveOneShotRegex: commentaryRegexCaseSensitiveOneShot,
   });
 
+export function isOldStyleLyrics(content) {
+  isContentString(content);
+
+  if (/^<i>/m.test(content)) {
+    throw new TypeError(
+      `Expected old-style lyrics block not to include <i> at start of any line`);
+  }
+
   return true;
 }
 
+export const isLyrics =
+  anyOf(
+    isOldStyleLyrics,
+    validateContentEntries({
+      headingPhrase: `lyrics heading`,
+      entryPhrase: `lyrics entry`,
+
+      caseInsensitiveRegex: commentaryRegexCaseInsensitive,
+      caseSensitiveOneShotRegex: commentaryRegexCaseSensitiveOneShot,
+    }));
+
 const isArtistRef = validateReference('artist');
 
 export function validateProperties(spec) {