pallets-eco / wtforms

A flexible forms validation and rendering library for Python.
https://wtforms.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.51k stars 395 forks source link

InputRequired send error only when data is None #844

Closed antoniosobrinho closed 4 months ago

antoniosobrinho commented 5 months ago

InputRequired return error when data is False or 0.

If my data is a Int or a Bool and I need them to be required, InputRequired return error if I send False or 0, but I send the data.

This fix check only if data is None, so, if the data exists

Daverball commented 5 months ago

raw_data should always be a list of strings (or file uploads, the representation of which depends on if you use Webob, Werkzeug or something else to parse your POST/GET formdata), essentially whatever MultiDict.getlist returns, if you pass in something else then you are not using the library correctly.

DataRequired actually has the issue you're trying to fix here, but InputRequired does not.