mirror of
https://github.com/Xevion/runnerspace.git
synced 2025-12-06 01:16:13 -06:00
Add better message hints to RegEx validators
I realized that users wouldn't be able to understand why their username was invalid, so rather than getting rid of it, I added message hints and split it up into two different validators. If the first one fails, the second one will show as well. Not perfect, but better than before by a longshot.
This commit is contained in:
5
forms.py
5
forms.py
@@ -6,7 +6,10 @@ from validators import NoProfanity
|
||||
|
||||
class RegistrationForm(FlaskForm):
|
||||
username = StringField('Username', [validators.Length(min=4, max=25),
|
||||
validators.Regexp(r' ^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$'),
|
||||
validators.Regexp(r'^[a-zA-Z0-9_\.]+$',
|
||||
message='Only letters, numbers, underscore character and dots are allowed.'),
|
||||
validators.Regexp(r'^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$',
|
||||
message='Dots and underscores cannot be at the start of the username, repeat or touch.'),
|
||||
NoProfanity()])
|
||||
name = StringField('Name', [validators.Length(min=2, max=35), NoProfanity()])
|
||||
password = PasswordField('New Password', [
|
||||
|
||||
Reference in New Issue
Block a user