-
Notifications
You must be signed in to change notification settings - Fork 35
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
Cannot validate raw integer 0 with required IntegerField. #39
Comments
Added a failing test case, no clue yet how to fix this. |
I believe that I understand the problem. If you look at the input required validator in wtforms https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py#L241 you see this code
The raw data is expected to be a string, even in an integer field. The error occurs when we give it raw data which is not a string, and happens to evaluate to false. If you convert integers to strings before giving them to the form (in fact you only need to convert 0, since it is the only integer which evaluates to false), then you pass the test case.
I'm not sure exactly how you would want to go about fixing this, since I noticed that if I converted all the integers to strings, I fail a bunch of your test cases with mismatches like
But that is what is going on. Cheers, Evan |
Try patching |
I'm having issues validating a required IntegerField when the JSON value passed is 0:
Using wtforms 2.0.2
The text was updated successfully, but these errors were encountered: