« get me outta code hell

data, test: type validation message adjustments - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-29 10:36:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-29 10:36:59 -0300
commite4dc2be4c12a5578bfb5d5945a592907aed1cb4f (patch)
tree71e3a201eba0889d1e912d5d049696f8a094bf09
parent90492f9e58251f63a1175d0e52d76f00fa78e3bf (diff)
data, test: type validation message adjustments
-rw-r--r--src/data/things/composite.js8
-rw-r--r--test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js4
2 files changed, 7 insertions, 5 deletions
diff --git a/src/data/things/composite.js b/src/data/things/composite.js
index 7a3a8319..c03f8833 100644
--- a/src/data/things/composite.js
+++ b/src/data/things/composite.js
@@ -4,6 +4,7 @@ import {colors} from '#cli';
 import {TupleMap} from '#wiki-data';
 
 import {
+  a,
   is,
   isString,
   isWholeNumber,
@@ -464,8 +465,8 @@ function validateInputValue(value, description) {
     } else {
       throw new TypeError(
         (type
-          ? `Expected ${type}, got ${typeAppearance(value)}`
-          : `Expected value, got ${typeAppearance(value)}`));
+          ? `Expected ${a(type)}, got ${typeAppearance(value)}`
+          : `Expected a value, got ${typeAppearance(value)}`));
     }
   }
 
@@ -478,7 +479,7 @@ function validateInputValue(value, description) {
         : typeof value);
 
     if (typeofValue !== type) {
-      throw new TypeError(`Expected ${type}, got ${typeAppearance(value)}`);
+      throw new TypeError(`Expected ${a(type)}, got ${typeAppearance(value)}`);
     }
   }
 
@@ -1997,6 +1998,7 @@ export const withPropertiesFromObject = templateCompositeFrom({
     object: input({type: 'object', acceptsNull: true}),
 
     properties: input({
+      type: 'array',
       validate: validateArrayItems(isString),
     }),
 
diff --git a/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js b/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js
index 01220a3a..c6fa7b21 100644
--- a/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js
+++ b/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js
@@ -168,7 +168,7 @@ t.test(`withResultOfAvailabilityCheck: validate static inputs`, t => {
   t.match(caughtError, {
     message: /Errors in input options passed to withResultOfAvailabilityCheck/,
     errors: [
-      /mode: Expected value, got null/,
+      /mode: Expected a value, got null/,
     ],
   });
 });
@@ -218,7 +218,7 @@ t.test(`withResultOfAvailabilityCheck: validate dynamic inputs`, t => {
       cause: {
         message: /Errors in input values provided to withResultOfAvailabilityCheck/,
         errors: [
-          /mode: Expected value, got null/,
+          /mode: Expected a value, got null/,
         ],
       },
     },