« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/validators.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/validators.js b/src/validators.js
index 2c3bd8e6..0300f629 100644
--- a/src/validators.js
+++ b/src/validators.js
@@ -196,9 +196,14 @@ export function is(...values) {
     };
   }
 
+  const joiner =
+    (Array.from(values).some(v => typeof v === 'string' && v.includes(' '))
+      ? ', '
+      : ' ');
+
   const fn = (value) => {
     if (!values.has(value)) {
-      throw new TypeError(`Expected one of ${Array.from(values).join(' ')}, got ${value}`);
+      throw new TypeError(`Expected one of ${Array.from(values).join(joiner)}, got ${value}`);
     }
 
     return true;