« get me outta code hell

validators: isDimensions: accept null width and/or height - 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>2024-04-13 15:42:14 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-13 15:47:35 -0300
commit3d1a1383e83b438dc3ffe0e3187fa2b36828d330 (patch)
treefd7d82d64fdcc65ce60dac3a87ebd5f200bd1cbd
parentfb6e7816d1911e9e2b218939d2b5c7eef22ab552 (diff)
validators: isDimensions: accept null width and/or height
-rw-r--r--src/data/validators.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/data/validators.js b/src/data/validators.js
index 46dd292d..987f806d 100644
--- a/src/data/validators.js
+++ b/src/data/validators.js
@@ -643,10 +643,15 @@ export function isDimensions(dimensions) {
 
   if (dimensions.length !== 2) throw new TypeError(`Expected 2 item array`);
 
-  isPositive(dimensions[0]);
-  isInteger(dimensions[0]);
-  isPositive(dimensions[1]);
-  isInteger(dimensions[1]);
+  if (dimensions[0] !== null) {
+    isPositive(dimensions[0]);
+    isInteger(dimensions[0]);
+  }
+
+  if (dimensions[1] !== null) {
+    isPositive(dimensions[1]);
+    isInteger(dimensions[1]);
+  }
 
   return true;
 }