Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Regex was only testing first character #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexwaters
Copy link

In my application I'm doing the following:

class ExtendedRegisterForm(RegisterForm):
    username = StringField('Username', [DataRequired(), Length(min=3, max=50),
                                        Regexp(r'^[A-Za-z0-9@#$%^&+=]+$', message='Username contains invalid characters'),
                                        UniqueUsername(message='Username taken')
                                        ])

and came across your similar code in searching http://nullege.com/codes/search/wtforms.validators.Regexp

I'm not 100%, but I think you may have the same issue that I had. I was overriding flask-security and using the above regex without the ^$ to denote start/stop and it was validating the field even if there were invalid characters. So long as the first character matched the pattern it came back valid (but subsequent characters could be invalid and the form would still validate).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant