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 new validator class - alpha numeric spaces #17435
Conversation
I think we have unit tests for existing validators so we'd want to add one for this. |
$this->validate('onlyalpha'); | ||
$this->validate(123); | ||
$this->validate('abc 123'); | ||
$this->validate('abc 123 and 0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to also test edge cases like German umlauts, some Chinese characters and maybe even some utf8 emojis maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely, I will do that 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more test cases with special characters. Emoji is not supported with this regex. Do you think we should let emojis as well?
$this->validate('abc 123'); | ||
$this->validate('ABC 123 and 0'); | ||
|
||
$this->assertTrue(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be better to use $this->expectNotToPerformAssertions();
instead of doing an assert that can't fail.
Also you could also use one test for all strings with a dataprovider, like for the failing ones.
I close this now as we don't need it. |
Description:
This new class will check if the validated field only contains alphanumeric characters and spaces. No special characters allowed.
Review