Add validator to file upload in corpus creation.

This commit is contained in:
Patrick Jentsch 2019-08-01 12:16:49 +02:00
parent 3964fe5444
commit ce6ec4af58

View File

@ -1,5 +1,5 @@
from flask_wtf import FlaskForm
from wtforms import MultipleFileField, SelectField, StringField, SubmitField
from wtforms import MultipleFileField, StringField, SubmitField
from wtforms.validators import DataRequired, Length
@ -8,12 +8,12 @@ class CreateCorpusForm(FlaskForm):
'Description',
validators=[DataRequired(), Length(1, 64)]
)
files = MultipleFileField('Files')
files = MultipleFileField('Files', validators=[DataRequired()])
submit = SubmitField('Create corpus')
title = StringField(
'Title',
validators=[DataRequired(), Length(1, 32)]
)
submit = SubmitField('Create corpus')
'''
def validate_files(form, field):
for file in form.files.getlist[field.name]: