Skip to content

Question: how validate File? #116

Closed
Svaroh/JsFormValidatorBundle
#18

Description

@acanthis

Dear developer!
I'm trying to validate file in my collection.

Entity collection type:
1472234977868

File entity type:
1472235156250

Constraints NotBlank good work:
1472235281198

When I try to select a file that does not meet the requirements, the validation does not work.
In a typical form submission validation file works correctly!
Thanks in advance for your reply.

Activity

  1. 66Ton99 commented on Aug 29, 2016

    @66Ton99
    Collaborator

    I think it does not implemented yet.

  2. acanthis commented on Aug 30, 2016

    @acanthis
    Author

    User @cleannoise realized validation file:
    https://github.com/cleannoise/JsFormValidatorBundle

    it works!

    1472535650065

    1472535784288

  3. added this to the milestone on Jul 6, 2017
  4. added a commit that references this issue on Aug 24, 2026
    a464e6a
  5. 66Ton99 commented on Aug 24, 2026

    @66Ton99
    Collaborator

    Fixed in Svaroh/JsFormValidatorBundle, the new home of this bundle, by PR #18.

    File is validated in the browser as far as the File API allows, so a file that is too large or has an unexpected mime type is reported before the upload starts:

    Option Checked with
    maxSize File.size
    mimeTypes File.type, type/* wildcards included
    extensions the extension of File.name
    filenameMaxLength the length of File.name in filenameCountUnit units
    empty file a File.size of zero

    The sizes are formatted the way FileValidator formats them, so the messages read exactly as the server-side ones. Everything that needs the content of the file - the real mime type, readability, the upload errors - stays on the server, and Image with its own geometry options is validated server side only.

    Documentation: 3_22.md.

    The fix is in the svaroh/jsformvalidator-bundle package on main. It is not backported to fp/jsformvalidator-bundle, which stays on its 1.x line, so upgrading to the new package is what picks it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions