<html><head></head><body><p dir="ltr">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 </p>
<p dir="ltr">if you get it working and think it will benefit others then post a blog and submit the code via a pull request </p>
<p dir="ltr">Sent from <a href="http://r.typeapp.com">Type Mail</a></p>
<div class="gmail_quote" >On Oct 19, 2015, at 07:02, Jim Icenhower via Flask <<a href="mailto:flask@python.org" target="_blank">flask@python.org</a>> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1445007835253_64473"><span>Hi,</span></div><div dir="ltr" id="yui_3_16_0_1_1445007835253_64475"><span id="yui_3_16_0_1_1445007835253_64474">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.</span></div><div dir="ltr" id="yui_3_16_0_1_1445007835253_64477"><span id="yui_3_16_0_1_1445007835253_64476">I think I'd like to do something like this:</span></div><div dir="ltr" id="yui_3_16_0_1_1445007835253_64478"><span class="" id="yui_3_16_0_1_1445007835253_64365" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
font-size: 0.85em; line-height: 1.3em; white-space: pre-wrap; color: rgb(0, 68, 97); font-weight: bold;">class</span><span style="color: rgb(62, 67, 73); font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em; line-height: 1.3em; white-space: pre-wrap; background-color: rgb(238, 238, 238);"> </span><span class="" id="yui_3_16_0_1_1445007835253_64367" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em; line-height: 1.3em; white-space: pre-wrap;">UploadForm</span><span class="" id="yui_3_16_0_1_1445007835253_64369" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em; line-height: 1.3em; white-space: pre-wrap; font-weight: bold;">(</span><span class="" id="yui_3_16_0_1_1445007835253_64371" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em;
line-height: 1.3em; white-space: pre-wrap;">Form</span><span class="" id="yui_3_16_0_1_1445007835253_64373" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em; line-height: 1.3em; white-space: pre-wrap; font-weight: bold;">):</span><br></div><pre style="overflow-x: auto; overflow-y: hidden; font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em; margin: 15px -30px; line-height: 1.3em; padding: 7px 30px; border-radius: 2px; color: rgb(62, 67, 73); background: rgb(238, 238, 238);" id="yui_3_16_0_1_1445007835253_64363" class="">    <span class="" style="color: rgb(0, 0, 0);" id="yui_3_16_0_1_1445007835253_64375">upload</span> <span class="" style="color: rgb(88, 40, 0);" id="yui_3_16_0_1_1445007835253_64377">=</span> <span class="" style="color: rgb(0, 0, 0);" id="yui_3_16_0_1_1445007835253_64379">FileField</span><span class="" style="color: rgb(0, 0, 0); font-weight:
bold;" id="yui_3_16_0_1_1445007835253_64381">(</span><span class="" style="color: rgb(78, 154, 6);" id="yui_3_16_0_1_1445007835253_64383">"Upload your Events file"</span><span class="" style="color: rgb(0, 0, 0); font-weight: bold;" id="yui_3_16_0_1_1445007835253_64385">,</span>
                       <span class="" style="color: rgb(0, 0, 0);" id="yui_3_16_0_1_1445007835253_64387">validators</span><span class="" style="color: rgb(88, 40, 0);" id="yui_3_16_0_1_1445007835253_64389">=</span><span class="" style="color: rgb(0, 0, 0); font-weight: bold;" id="yui_3_16_0_1_1445007835253_64391">[</span><span class="" style="color: rgb(0, 0, 0);" id="yui_3_16_0_1_1445007835253_64393">file_required</span><span class="" style="color: rgb(0, 0, 0); font-weight: bold;" id="yui_3_16_0_1_1445007835253_64395">(),</span>
                                   <span class="" style="color: rgb(0, 0, 0);" id="yui_3_16_0_1_1445007835253_64397">file_required_fields</span><span class="" style="color: rgb(0, 0, 0); font-weight: bold;" id="yui_3_16_0_1_1445007835253_64399">(</span><span class="" style="color: rgb(0, 0, 0);" id="yui_3_16_0_1_1445007835253_64401">Events</span><span class="" style="color: rgb(0, 0, 0); font-weight: bold;" id="yui_3_16_0_1_1445007835253_64403">,</span> <span class="" style="color: rgb(78, 154, 6);" id="yui_3_16_0_1_1445007835253_64405">"Images only!"</span><span class="" style="color: rgb(0, 0, 0); font-weight: bold;" id="yui_3_16_0_1_1445007835253_64407">)])</span></pre><div></div><div dir="ltr" id="yui_3_16_0_1_1445007835253_64479">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.</div><div dir="ltr" id="yui_3_16_0_1_1445007835253_64480"><br></div><div dir="ltr"
id="yui_3_16_0_1_1445007835253_64481">Thanks!</div><div id="yui_3_16_0_1_1445007835253_64482"><br></div><div class="signature" id="yui_3_16_0_1_1445007835253_64483">Jim
</div></div><pre class="blue"><hr><br>Flask mailing list<br>Flask@python.org<br><a href="https://mail.python.org/mailman/listinfo/flask">https://mail.python.org/mailman/listinfo/flask</a><br></pre></blockquote></div></body></html>