diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-01-05 22:02:27 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-01-06 12:50:30 -0400 |
commit | 01a1e04649907aaf73564b3442f683cab73c3a78 (patch) | |
tree | bf6e23aab390d4682f0af25acf2a3eaa6850ffa4 | |
parent | f46e4c2eba7cfc194907e767893e8c89c072c338 (diff) |
validators, test: define various validators with isContentString
-rw-r--r-- | src/data/things/validators.js | 12 | ||||
-rw-r--r-- | test/unit/data/things/validators.js | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/data/things/validators.js b/src/data/things/validators.js index bff2b703..1ef23d07 100644 --- a/src/data/things/validators.js +++ b/src/data/things/validators.js @@ -299,7 +299,7 @@ export function isColor(color) { } export function isCommentary(commentaryText) { - isString(commentaryText); + isContentString(commentaryText); const rawMatches = Array.from(commentaryText.matchAll(commentaryRegex)); @@ -546,15 +546,15 @@ export const isContribution = validateProperties({ export const isContributionList = validateArrayItems(isContribution); export const isAdditionalFile = validateProperties({ - title: isString, - description: optional(isStringNonEmpty), + title: isName, + description: optional(isContentString), files: validateArrayItems(isString), }); export const isAdditionalFileList = validateArrayItems(isAdditionalFile); export const isTrackSection = validateProperties({ - name: optional(isString), + name: optional(isName), color: optional(isColor), dateOriginallyReleased: optional(isDate), isDefaultTrackSection: optional(isBoolean), @@ -614,7 +614,7 @@ export function isLanguageCode(string) { } export function isName(name) { - return isString(name); + return isContentString(name); } export function isURL(string) { @@ -748,7 +748,7 @@ export function validateWikiData({ export const isAdditionalName = validateProperties({ name: isName, - annotation: optional(isStringNonEmpty), + annotation: optional(isContentString), // TODO: This only allows indicating sourcing from a track. // That's okay for the current limited use of "from", but diff --git a/test/unit/data/things/validators.js b/test/unit/data/things/validators.js index 178f8657..8fed27ff 100644 --- a/test/unit/data/things/validators.js +++ b/test/unit/data/things/validators.js @@ -227,7 +227,7 @@ t.test('isName', t => { t.plan(4); t.ok(isName('Dogz 2.0')); t.ok(isName('album:this-track-is-only-named-thusly-to-give-niklink-a-headache')); - t.ok(isName('')); + t.throws(() => isName('')); t.throws(() => isName(612)); }); |