« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/things/validators.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/data/things/validators.js b/src/data/things/validators.js
index 27416bb2..d881aac2 100644
--- a/src/data/things/validators.js
+++ b/src/data/things/validators.js
@@ -262,6 +262,16 @@ export function sparseArrayOf(itemValidator) {
   });
 }
 
+export function looseArrayOf(itemValidator) {
+  return validateArrayItems((item, index, array) => {
+    if (item === false || item === null || item === undefined) {
+      return true;
+    }
+
+    return itemValidator(item, index, array);
+  });
+}
+
 export function validateInstanceOf(constructor) {
   const fn = (object) => isInstance(object, constructor);