[Flask] Can I write my own WTF file validator?

David Baumgold david at davidbaumgold.com
Mon Oct 19 16:48:49 CEST 2015


Jim, here’s the documentation for writing custom validators: http://wtforms.readthedocs.org/en/latest/validators.html#custom-validators

From: Tiger Nassau <tigernassau at gmail.com>
Reply: Tiger Nassau <tigernassau at gmail.com>
Date: October 19, 2015 at 10:46:22 AM
To: Jim Icenhower <jicenhower at yahoo.com>
CC: flask at python.org <flask at python.org>
Subject:  Re: [Flask] Can I write my own WTF file validator?  

you must be a windows person (: this is open source and you can do anything you want to your app - just try out your idea and test - its only form stuff so should not break too much of the app if it does not work   post any specific errors and others can help more

if you get it working and think it will benefit others then post a blog and submit the code via a pull request

Sent from Type Mail

On Oct 19, 2015, at 07:02, Jim Icenhower via Flask <flask at python.org> wrote:
Hi,
I'm creating an import using Flask, WTF and Flask Appbuilder. I see that the Flask WTF FileField allows validators. Can I create my own? I want to check that required fields are populated on every record in the uploaded file. I'd like to pass a class to the validator that contains the required fields so I can use this routine for many different record types.
I think I'd like to do something like this:

class  
UploadForm(Form):
    upload = FileField("Upload your Events file",
                       validators=[file_required(),
                                   file_required_fields(Events, "Images only!")])
Is this possible? If so, what class to I extend/inherit from to create my validator? I'm a Java developer but a total newbie to Python/Flask.

Thanks!

Jim

Flask mailing list
Flask at python.org
https://mail.python.org/mailman/listinfo/flask

_______________________________________________  
Flask mailing list  
Flask at python.org  
https://mail.python.org/mailman/listinfo/flask  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20151019/31bbaa98/attachment-0001.html>


More information about the Flask mailing list