From e4dc2be4c12a5578bfb5d5945a592907aed1cb4f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Sep 2023 10:36:59 -0300 Subject: data, test: type validation message adjustments --- src/data/things/composite.js | 8 +++++--- .../composite/common-utilities/withResultOfAvailabilityCheck.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data/things/composite.js b/src/data/things/composite.js index 7a3a831..c03f883 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 01220a3..c6fa7b2 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/, ], }, }, -- cgit 1.3.0-6-gf8a5