From c56a1eb78b76b52cbeeed6fe16d3511c1fd41147 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 8 Feb 2022 09:46:22 -0400 Subject: super basic album ↔ track linking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thing/validators.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/thing/validators.js') diff --git a/src/thing/validators.js b/src/thing/validators.js index 1bc7fd72..83922229 100644 --- a/src/thing/validators.js +++ b/src/thing/validators.js @@ -96,7 +96,7 @@ export function isStringNonEmpty(value) { // Complex types (non-primitives) -function isInstance(value, constructor) { +export function isInstance(value, constructor) { isObject(value); if (!(value instanceof constructor)) @@ -133,7 +133,11 @@ export function isArray(value) { function validateArrayItemsHelper(itemValidator) { return (item, index) => { try { - itemValidator(item); + const value = itemValidator(item); + + if (value !== true) { + throw new Error(`Expected validator to return true`); + } } catch (error) { error.message = `(index: ${color.green(index)}, item: ${inspect(item)}) ${error.message}`; throw error; -- cgit 1.3.0-6-gf8a5