Skip to content
Snippets Groups Projects

model.base: fix id_short validation

Merged Leon Mauritz Möller requested to merge fix/id_short_validation into improve/V30RC01

In RegEx, the $ asserts the end of a string or line. When used in re.match() it asserts the end of the string by default, unless the last character is a newline symbol (\n). Then it asserts the end of the string before the newline. Thus the first regex check doesn't filter valid id_shorts ending in a newline, which it should. See https://docs.python.org/3.9/library/re.html#index-2

Using re.fullmatch() instead fixes this issue, making the ^ and $ unnecessary as well.

Next to adding a test for this behaviour this commit also simplifies the check for an alphabetical character at the start of the id_short. And although both checks could also be merged into one, they are left separate to be able to report more accurate errors.

Merge request reports

Merge train pipeline #456327 passed

Merge train pipeline passed for 9ac395e1

Test coverage 87.00% (0.00%) from 1 job

Merged by Torben MinyTorben Miny 3 years ago (Apr 28, 2021 2:26pm UTC)

Loading

Pipeline #456330 passed

Pipeline passed for cfd95fb3 on improve/V30RC01

Test coverage 87.00% (0.00%) from 1 job

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading