flask-pydantic icon indicating copy to clipboard operation
flask-pydantic copied to clipboard

Validate request.form arguments from HTML post form

Open damianhorna opened this issue 2 years ago • 1 comments

Hi,

not sure whether there is an option to validate request.form arguments right now, with this package but it would be a nice-to-have feature :)

For example, to use like this: @validate(form=SomeModel)

Right now, I am validating request.form simply like this:

    try:
        form = LoginFormModel(**request.form)
    except ValidationError as ve:
        return {"validation_error": ve.errors()}, 400

Or is there any other way around?

Any advice would be much appreciated!

damianhorna avatar Sep 13 '21 09:09 damianhorna

Hello,

this would indeed be a nice feature. This package does not support forms yet. I will try to find time to implement it. Feel free to submit PR.

Thank you for suggestion!

bauerji avatar Sep 13 '21 11:09 bauerji