Skip to content

Optional() disables all other validators... #624

@himarange

Description

@himarange

When adding Optional() in the validators list, all other validators seem to disqualify.
For example:

class ModifyLinkForm(FlaskForm):
    description = TextAreaField('Description', validators=[
        Optional()
        , Length(max=256)
        , Regexp(r"^[a-zA-Z0-9\s.,!?\"'()\-\:_]+$", message="Invalid characters in description.")
        ])

Will ignore the Length, and the Regex validators.
I need to accept empty string and None, but as soon as there is data, I need validation.

Environment:

  • Python version: 3.9.13
  • Flask-WTF version: 1.2.1
  • Flask version: 3.03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions