diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-04 13:33:02 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-24 11:55:20 -0300 |
commit | 4ade3580af1a918e057d693501820b1d7e6a7c90 (patch) | |
tree | a08f46a8f7898ca344a236fbe47b59b89bbb223f /src/data/validators.js | |
parent | 012fe56cb483bd3b87354ecb48c433757a636cb7 (diff) |
validators: isThing
Diffstat (limited to 'src/data/validators.js')
-rw-r--r-- | src/data/validators.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/data/validators.js b/src/data/validators.js index e3e56122..976e6217 100644 --- a/src/data/validators.js +++ b/src/data/validators.js @@ -613,6 +613,17 @@ export function isThingClass(thingClass) { return true; } +export function isThing(thing) { + isObject(thing); + isFunction(thing.constructor); + + if (!Object.hasOwn(thing.constructor, Symbol.for('Thing.referenceType'))) { + throw new TypeError(`Expected a Thing, constructor missing Thing.referenceType`); + } + + return true; +} + export const isContribution = validateProperties({ artist: isArtistRef, annotation: optional(isStringNonEmpty), |