Skip to content

Should forms be validated without request data? #806

@azmeuk

Description

@azmeuk

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.

  • One want users to be able to save a form and continue editing later. So the forms get saved in a database even if validation fails, and then when users want to continue, the form is restored from the database, and validated so users get indications about the state of the form.
  • One wants to initialize a form with some faulty default values, and give users indications about what is needed to improve the form.

Do you people have met that kind of situations in real-world use-cases?

Any thought on whether this should be supported in wtforms?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about WTForms behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions