pallets-eco / pallets-eco/wtforms

Email() validation failed should raise a StopValidation error

Open
#360 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.6k
Forks
409
PR merge metrics
No merged PRs in 30d

Description

Look at this case:

class UserForm(FlaskForm):
    email = StringField('email', validators=[Email()])

    def validate_email(self, field):
        if not User.query.filter_by(email=email).first():
           raise ...

If input is not a email, validate_email will still be executed, which make no sense. So I think Email should raise a StopValidation error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Email() validator and StopValidation behavior, then follow how the validate_email method is invoked after field validation fails. Check the existing validation tests and add coverage for invalid email input to confirm whether the custom validator should be skipped.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.