-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
Should forms be validated without request data? #806
Comments
My humble opinion is that all data passed to the Form should be validated. Either in formdata= or data= Because my use case is: I render the form in HTML, but I send the form data via ajax. Then I load the data into the backend using MyForm(data=data) and want to validate this data. |
I think it is valuable to distinguish between form data and object data, especially for things like That being said, I think the main issue here is how It would simplify things a lot if it instead was a property of the field. That means the field can deal with whether or not expects data to be present in the various We could keep things as flexible as they are right now with validators by making |
Thanks @Daverball for the explanation. We ran into this issue, and switching to use |
Recent tickets (#804 , #769) suggest that people want to validate forms without request data. This means people want to validate forms that are not initialized with real HTML form data.
Currently the documentation is not very clear whether this is allowed or not. Most of the time the code works, but sometimes not and I believe this is the cause of some bug reports.
If we decide this is not supported, then we might want to document this.
If we decide this is supported, then we need to list the implications in the code. I can think at least of making the validators work with python native types (and not just request form strings).
I can think at least of two situation where that could be useful, though I never met it directly.
Do you people have met that kind of situations in real-world use-cases?
Any thought on whether this should be supported in wtforms?
The text was updated successfully, but these errors were encountered: