diff options
Diffstat (limited to 'src/data')
-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); |