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

Is there a way to include isAlpha with spaces yet? #1282

Closed
christopherbclark opened this issue Apr 19, 2020 · 7 comments · Fixed by #1286
Closed

Is there a way to include isAlpha with spaces yet? #1282

christopherbclark opened this issue Apr 19, 2020 · 7 comments · Fixed by #1286

Comments

@christopherbclark
Copy link

I saw a thread from 2018 where it was suggested that this feature would not be implemented. Has anyone revisited this recently? It's a huge gap, in my opinion. If it is available now, could someone please direct me on how to use it?

@ezkemboi
Copy link
Member

@christopherbclark can you give an example of the input you are trying to validate for clarification.
I might help easily check if it is available or not. If it is not available and worth adding (With people vote for it), definitely it can be added and made available in the next version.

@christopherbclark
Copy link
Author

christopherbclark commented Apr 20, 2020

Sure! So, for example, if I had a database field for "project name", and I only wanted it to include letters, and spaces. Looking for a validator that would accept "My Awesome Project", but reject "My Awesome Project 99". Right now, I think both would be rejected using isAlpha because they include spaces. From the earlier stuff I read, this is because a space is neither alpha or numeric, and therefore fails.

@ezkemboi
Copy link
Member

I get your point @christopherbclark. At the moment, isAlpha() does not accept that.
Unless people vote for the addition of isAlpha() with an option to have spaces or create something like isAlphaWithSpace()

@profnandaa
Copy link
Member

I'd suggest just adding a config object as we've been doing with the rest, scales better, so -> isAlpha(str, locale, { config object }

How about if we had an ignoreList instead that lists characters in a string?

isAlpha("my project", "en-US", { ignoreList: " " }); // true
isalpha("my awesome-project", "en-US", { ignoreList: " -" }); // true

@ezkemboi
Copy link
Member

Looks great suggestion @profnandaa.

@christopherbclark
Copy link
Author

I agree. Can we put @profnandaa ‘s idea to a formal vote? I think a feature like that would be super cool.

@mum-never-proud
Copy link
Contributor

we definitely need more consider edge cases and write more test case I hope this should be the beginning

note I forgot to update fork, will clean up

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

Successfully merging a pull request may close this issue.

4 participants