« get me outta code hell

always show "expected array" during validation - 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>2022-05-12 19:01:23 -0300
committer(quasar) nebula <qznebula@protonmail.com>2022-05-12 19:01:23 -0300
commita453db3ee0152ecf3c70dce5fae516b80a9eb014 (patch)
tree8487230190cf883d1306fba2a3a77295cec0c4c0
parent0b9c1c230594d80b92f3d0d2dda380ff8de7a1a0 (diff)
always show "expected array" during validation
...instead of "expected object" if the value isn't an object.
-rw-r--r--src/data/validators.js4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/data/validators.js b/src/data/validators.js
index 2d90987..1ac8c33 100644
--- a/src/data/validators.js
+++ b/src/data/validators.js
@@ -129,9 +129,7 @@ export function isObject(value) {
 }
 
 export function isArray(value) {
-    isObject(value);
-
-    if (!Array.isArray(value))
+    if (typeof value !== 'object' || value === null || !Array.isArray(value))
         throw new TypeError(`Expected an array, got ${value}`);
 
     return true;