Skip to content

added validation on tagname#286

Merged
sroderick-g5sro merged 3 commits intomasterfrom
261-improve-tag-checking
Sep 22, 2020
Merged

added validation on tagname#286
sroderick-g5sro merged 3 commits intomasterfrom
261-improve-tag-checking

Conversation

@sroderick-g5sro
Copy link
Copy Markdown
Contributor

@sroderick-g5sro sroderick-g5sro commented Sep 16, 2020

Fixes #261.

Copy link
Copy Markdown
Contributor

@jonc125 jonc125 left a comment

Choose a reason for hiding this comment

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

I can confirm that this works as expected, albeit it doesn't solve #272 or #229 unfortunately. It would be good if the error message said what was valid, e.g. add (only letters, numbers, dashes or underscores are allowed).

Comment thread weblab/entities/forms.py Outdated
tag = forms.CharField(
help_text='Optional short label for this version',
required=False)
required=False, validators=[RegexValidator(r'[-_A-Za-z0-9]', 'Please enter a valid tag name.')])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a stylistic thing: it's best practice to have each arg on a separate line when they don't all fit on one.

Suggested change
required=False, validators=[RegexValidator(r'[-_A-Za-z0-9]', 'Please enter a valid tag name.')])
required=False,
validators=[RegexValidator(r'[-_A-Za-z0-9]', 'Please enter a valid tag name.')])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The other occurrence is done, but you missed this one :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry, changed that now

Comment thread weblab/entities/forms.py Outdated
label='New tag',
help_text='Short label for this version',
required=True)
required=True, validators=[RegexValidator(r'[-_A-Za-z0-9]', 'Please enter a valid tag name.')])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
required=True, validators=[RegexValidator(r'[-_A-Za-z0-9]', 'Please enter a valid tag name.')])
required=True,
validators=[RegexValidator(r'[-_A-Za-z0-9]', 'Please enter a valid tag name.')])

Copy link
Copy Markdown
Contributor

@jonc125 jonc125 left a comment

Choose a reason for hiding this comment

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

Great!

@sroderick-g5sro sroderick-g5sro merged commit f9c5ba4 into master Sep 22, 2020
@sroderick-g5sro sroderick-g5sro deleted the 261-improve-tag-checking branch September 22, 2020 11:58
MauriceHendrix pushed a commit that referenced this pull request Jul 22, 2021
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.

Improve checking of tag names

2 participants