diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-12-30 08:56:26 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-12-30 16:26:34 -0400 |
commit | 7f39e10beee71ea0c45db3ff9b2f6d6ae383bd3b (patch) | |
tree | 31f8ea83f9d8cc726223c702fd73ae41d7994f4f /src/data/things | |
parent | dc29162482b70a5ed9fe3c889a8fc29d001c8e80 (diff) |
validators: looseArrayOf
Diffstat (limited to 'src/data/things')
-rw-r--r-- | src/data/things/validators.js | 10 |
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); |