sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

string.nonBlank validator #226

Closed leaumar closed 2 years ago

leaumar commented 2 years ago

I often miss having a nonBlank validator for strings. nonEmpty allows " " and other whitespace strings, which are usually just as invalid as "". Some other validators like alphanumeric double as non-blank, but have additional constraints that aren't always ok.

I use non-blank as terminology because of apache-commons StringUtils in java, it's short and clear. nonWhitespace is more unwieldy, but whatever the devs prefer is ok with me.

I think it should be trivial to whip up an implementation by copying nonEmpty. Just wanted to test the water before getting started on a PR for what might be rejected right off the bat.

👍 or 👎 ?

leaumar commented 2 years ago

On a related note, is this project not supposed to just work if you get the right node version and npm install? I can't find any further instructions in the repo. (it works with --force, but yeah)

PS C:\Users\leaumar\Projects\ow> nvs use PATH -= C:\Users\leaumar\scoop\apps\nvs\current\nodejs\node\14.16.1\x64 PATH += C:\Users\leaumar\scoop\apps\nvs\current\nodejs\default PS C:\Users\leaumar\Projects\ow> npm install npm notice npm notice New major version of npm available! 7.20.3 -> 8.1.3 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.3 npm notice Run npm install -g npm@8.1.3 to update! npm notice npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: ow@0.28.1 npm ERR! Found: typescript@4.5.0-dev.20211101 npm ERR! node_modules/typescript npm ERR! dev typescript@"^4.5.0-beta" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer typescript@">=2.7" from ts-node@10.4.0 npm ERR! node_modules/ts-node npm ERR! dev ts-node@"^10.4.0" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See C:\Users\leaumar\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\leaumar\AppData\Local\npm-cache_logs\2021-11-10T12_53_15_414Z-debug.log