diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-05-11 19:58:06 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-05-11 19:58:06 -0300 |
| commit | 42723c7d476a0ac0595b802e25df38ef27abc208 (patch) | |
| tree | eaad403cfa09546bcc8919e4b39e6cdb4bde5397 /src | |
| parent | ae238fcd365f6b668828768e7bae6640414a4a21 (diff) | |
validators: is: handle strings with spaces nicer
Diffstat (limited to 'src')
| -rw-r--r-- | src/validators.js | 7 |
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; |