DataRequired and NumberRange can't handle 0
mickkn opened this issue · comments
Mick Kirkegaard commented
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