Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataRequired and NumberRange can't handle 0 #587

Open
mickkn opened this issue Nov 9, 2023 · 0 comments
Open

DataRequired and NumberRange can't handle 0 #587

mickkn opened this issue Nov 9, 2023 · 0 comments

Comments

@mickkn
Copy link

mickkn commented Nov 9, 2023

0 (zero) value not allowed for DecimalField with NumberRange validator for DataRequired

latitude = DecimalField(
    validators=[DataRequired(), NumberRange(min=-90, max=90)],
    render_kw={
        "placeholder": "Latitude, e.g. 55.9397°",
        "title": "Latitude",
    },
    places=6,
)

The problem seems to be the DataRequired that checks "if field.data" which I assume should be if field.data is not None

Could use InputRequired instead, but for some users, this field is ReadOnly in my application, which means that InputRequired is not validated correctly either.

0 is between -90 and 90

Environment:

  • Python version: 3.10.9
  • Flask-WTF version:1.2.1
  • Flask version:2.3.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant