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 new validator class - alpha numeric spaces #17435

Closed
wants to merge 3 commits into from

Conversation

flamisz
Copy link
Contributor

@flamisz flamisz commented Apr 8, 2021

Description:

This new class will check if the validated field only contains alphanumeric characters and spaces. No special characters allowed.

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@diosmosis
Copy link
Member

I think we have unit tests for existing validators so we'd want to add one for this.

@flamisz flamisz added the Needs Review PRs that need a code review label Apr 8, 2021
$this->validate('onlyalpha');
$this->validate(123);
$this->validate('abc 123');
$this->validate('abc 123 and 0');
Copy link
Member

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

Copy link
Contributor Author

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 👍

Copy link
Contributor Author

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);
Copy link
Member

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.

@flamisz flamisz removed the Needs Review PRs that need a code review label Apr 12, 2021
@flamisz flamisz marked this pull request as draft April 12, 2021 04:46
@flamisz
Copy link
Contributor Author

flamisz commented Apr 27, 2021

I close this now as we don't need it.

@flamisz flamisz closed this Apr 27, 2021
@sgiehl sgiehl deleted the new-validatior-alpha-num-spaces branch April 5, 2023 16:36
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.

None yet

3 participants