-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
validators.NumberRange doesn't handle NaN #505
Labels
bug
Unexpected behavior
Comments
I could reproduce this with both >>> import wtforms
>>> from tests.common import DummyPostData
>>> class F(wtforms.Form):
... a = wtforms.DecimalField(validators=[wtforms.validators.NumberRange(min=0, max=1)])
>>> F(DummyPostData({"a": "NaN"})).validate()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/azmeuk/dev/wtforms/wtforms/form.py", line 310, in validate
return super(Form, self).validate(extra)
File "/home/azmeuk/dev/wtforms/wtforms/form.py", line 152, in validate
if not field.validate(self, extra):
File "/home/azmeuk/dev/wtforms/wtforms/fields/core.py", line 206, in validate
stop_validation = self._run_validation_chain(form, chain)
File "/home/azmeuk/dev/wtforms/wtforms/fields/core.py", line 226, in _run_validation_chain
validator(form, self)
File "/home/azmeuk/dev/wtforms/wtforms/validators.py", line 134, in __call__
if data is None or (self.min is not None and data < self.min) or
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
[<class 'decimal.InvalidOperation'>] |
azmeuk
added a commit
to azmeuk/wtforms
that referenced
this issue
Apr 17, 2020
azmeuk
added a commit
to azmeuk/wtforms
that referenced
this issue
Apr 17, 2020
azmeuk
added a commit
to azmeuk/wtforms
that referenced
this issue
Apr 17, 2020
azmeuk
added a commit
to azmeuk/wtforms
that referenced
this issue
Apr 18, 2020
azmeuk
added a commit
to azmeuk/wtforms
that referenced
this issue
Apr 20, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Validating a
DecimalField
with aNumberRange
validator throws adecimal.InvalidOperation
exception when the value of the field is NaN. I would expect validation to fail insteadThe text was updated successfully, but these errors were encountered: