Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string.nonBlank #227

Merged
merged 2 commits into from
Nov 15, 2021
Merged

Add string.nonBlank #227

merged 2 commits into from
Nov 15, 2021

Conversation

leaumar
Copy link
Contributor

@leaumar leaumar commented Nov 10, 2021

fixes #226

Useful for all kinds of user/file/env sourced inputs that may contain strings of whitespace where a meaningful value is expected.

test/string.ts Outdated Show resolved Hide resolved
@@ -127,6 +127,16 @@ export class StringPredicate extends Predicate<string> {
});
}

/**
Test a string to be not empty nor only whitespace.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be written more clearly.

source/predicates/string.ts Outdated Show resolved Hide resolved
source/predicates/string.ts Outdated Show resolved Hide resolved
test/string.ts Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add string.nonBlank validator Add string.nonBlank Nov 11, 2021
@leaumar
Copy link
Contributor Author

leaumar commented Nov 11, 2021

I tried to run the tests, but...

PS D:\Projects\ow> npm test

ow@0.28.1 test
xo && c8 ava

TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
at open (node:internal/fs/promises:410:10)
at Object.readFile (node:internal/fs/promises:755:20)
at Object.load (file:///D:/Projects/ow/node_modules/esm-utils/lib/json.js:7:36)
at handleTSConfig (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:164:33)
at mergeWithFileConfig (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:138:19)
at async parseOptions (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:557:51)
at async Promise.all (index 0)
at async getOptionGroups (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:573:21)
at async Object.lintFiles (file:///D:/Projects/ow/node_modules/xo/index.js:69:17)
at async file:///D:/Projects/ow/node_modules/xo/cli.js:211:18

@leaumar
Copy link
Contributor Author

leaumar commented Nov 13, 2021

Alright, if the last open point (making the wording clearer) is solved for you, I have no remaining points other than not being able to run the tests.

@leaumar
Copy link
Contributor Author

leaumar commented Nov 13, 2021

Found a list of metachars in js, turns out there are only 6 so I figured I'd add them to stop at a logical point. \f and \v aren't so common but I can imagine \0 popping up in places. Had to write \0 as \x00 because my IDE thinks it's an error otherwise, even though it works fine in a js console.

@sindresorhus
Copy link
Owner

CI is failing

@leaumar
Copy link
Contributor Author

leaumar commented Nov 14, 2021

Try it now?

@leaumar
Copy link
Contributor Author

leaumar commented Nov 14, 2021

Oh, yeah, a null byte wouldn't actually be whitespace. I'll remove that, then it should be good.
image

@sindresorhus sindresorhus merged commit 96207f0 into sindresorhus:main Nov 15, 2021
@sindresorhus
Copy link
Owner

@leaumar We unfortunately cannot release this until TS supports ESM, but in the meantime, you can install this with npm i 'sindresorhus/ow#96207f00f3b3ab8b79e258f892ec948731a8cfd4'.

@leaumar leaumar deleted the string.nonblank branch November 15, 2021 16:19
@leaumar
Copy link
Contributor Author

leaumar commented Nov 15, 2021

Sounds like something that could take months still, if ever?

@sindresorhus
Copy link
Owner

It will be in TS 4.6 (was supposed to be in this release, but pulled last minute). So probably a month or two. TS 4.5 is scheduled to be out today.

@leaumar
Copy link
Contributor Author

leaumar commented Nov 15, 2021

Ah, cool. Thanks for the pointer

@sindresorhus
Copy link
Owner

This is finally out: https://github.com/sindresorhus/ow/releases/tag/v1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

string.nonBlank validator
2 participants