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

Add support for multiple file validation

Open greyli opened this issue 7 years ago • 5 comments

Add MultipleFileField, FilesRequired, FilesAllowed to support multiple files validation.

Closes #337

greyli avatar Jun 04 '18 01:06 greyli

Codecov Report

Merging #338 into master will increase coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #338      +/-   ##
==========================================
+ Coverage   99.67%   99.69%   +0.02%     
==========================================
  Files          18       18              
  Lines         911      986      +75     
  Branches       74       82       +8     
==========================================
+ Hits          908      983      +75     
  Misses          3        3
Impacted Files Coverage Δ
tests/test_file.py 100% <100%> (ø) :arrow_up:
flask_wtf/file.py 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 73e8c58...7188dd9. Read the comment docs.

codecov-io avatar Jun 04 '18 02:06 codecov-io

I experimented with this back when I made the WTForms PR, I'm trying to remember the design decisions I made.

I think that while the fields were separate so it was clear what was intended, I was trying to make the validators work for both single and multiple files (rather than adding extra validators or a multiple=True flag). Do you or @lepture agree with that?

Also might be interesting to add a test of the Length validator on the multiple field.

davidism avatar Jun 04 '18 03:06 davidism

Sounds good to me.

greyli avatar Jun 04 '18 07:06 greyli

I'd love to see this merged. Anything I can help with?

theomega avatar Jun 22 '19 15:06 theomega

Codecov Report

Merging #338 into master will decrease coverage by 1.33%. The diff coverage is 81.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #338      +/-   ##
==========================================
- Coverage   97.97%   96.63%   -1.34%     
==========================================
  Files          18       18              
  Lines         936     1011      +75     
  Branches       73       81       +8     
==========================================
+ Hits          917      977      +60     
- Misses         17       31      +14     
- Partials        2        3       +1     
Impacted Files Coverage Δ
tests/test_file.py 78.18% <76.00%> (-2.78%) :arrow_down:
flask_wtf/file.py 90.62% <89.65%> (-1.05%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d41f3bc...beb8623. Read the comment docs.

codecov-commenter avatar Sep 17 '20 00:09 codecov-commenter

Any chance of this being merged? :)

misilot avatar Nov 07 '22 16:11 misilot

Any chance of this being merged? :)

Hoping the same. @azmeuk can you review this please?

PanderMusubi avatar Nov 21 '22 10:11 PanderMusubi

This PR may not be merged.

I was planning to implement what David recommended as an alternative to this PR in January, but I was too busy with work. Maybe I will have time to make another PR next month. BTW, I'm also happy to review a PR!

greyli avatar Nov 21 '22 12:11 greyli

Hi guys, I finally re-implemented this in #556. With the new PR, the FileRequired, FileAllowed, and FileSize can be used for both single or multiple files.

greyli avatar Mar 08 '23 14:03 greyli