with current FileRequired and FileAllowed validators it's not possible for file field to be optionnal

Issue #5 invalid
Anonymous created an issue

both validators should be only one with an option to specify that the file is required that way one can make a file field optionnal.

{{{

!python

def FileValidation(required=False, require_message=None, set=None): def _file_required(form, field): file = getattr(field, "file", None)

    if required:
        if file.filename is None:
            raise validators.StopValidation(require_message)
    else:
        if file.filename:
            file_allowed(images)(form, field)
return _file_required

}}}

Comments (2)

  1. Matthew Frazier repo owner

    Sir. Anything related to FileRequired is a Flask-WTF issue, NOT a Flask-Uploads issue. The FileRequired validator is not part of Flask-Uploads, it is part of Flask-WTF. The only time Flask-Uploads touches a FileStorage object is when one is passed to the UploadSet.save method. Any form validation helpers are provided by Flask-WTF.

    Report the issue at https://bitbucket.org/danjac/flask-wtf/issues where Dan Jacob, the maintainer of Flask-WTF, can resolve it. If you continue to post bug reports regarding software that I do not maintain, I will contact the Bitbucket staff and have them deal with you appropriately.

    Repeated in French: Le "FileRequired" validateur n'est pas une partie de Flask-Uploads. C'est une partie de Flask-WTF. S'il vous plaît de signaler tout problème liés à la validation sur la page du projet Flask-WTF.

  2. Log in to comment