« get me outta code hell

data: inputThingClass -> isThingClass, use global Thing symbols - 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>2024-01-20 16:32:56 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-30 07:59:39 -0400
commit4739ac5fae824c6c985fca9ae34f6335f5c9c13e (patch)
tree571de29898c4702c2ddcf7661bd6f86f17bc650c /src/data/things
parente57e540bd57ea9b25cf785327054f344347c40b1 (diff)
data: inputThingClass -> isThingClass, use global Thing symbols
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/validators.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/data/things/validators.js b/src/data/things/validators.js
index d02e5f28..efe76fe0 100644
--- a/src/data/things/validators.js
+++ b/src/data/things/validators.js
@@ -595,6 +595,16 @@ export function isContentString(content) {
   return true;
 }
 
+export function isThingClass(thingClass) {
+  isFunction(thingClass);
+
+  if (!Object.hasOwn(thingClass, Symbol.for('Thing.referenceType'))) {
+    throw new TypeError(`Expected a Thing constructor, missing Thing.referenceType`);
+  }
+
+  return true;
+}
+
 export const isContribution = validateProperties({
   who: isArtistRef,
   what: optional(isStringNonEmpty),