You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear developer!
I'm trying to validate file in my collection.
Entity collection type:
File entity type:
Constraints NotBlank good work:
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.
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.
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.
Activity
66Ton99 commentedon Aug 29, 2016
I think it does not implemented yet.
acanthis commentedon Aug 30, 2016
User @cleannoise realized validation file:
https://github.com/cleannoise/JsFormValidatorBundle
it works!
feat(js): validate the File constraint in the browser
66Ton99 commentedon Aug 24, 2026
Fixed in Svaroh/JsFormValidatorBundle, the new home of this bundle, by PR #18.
Fileis 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:maxSizeFile.sizemimeTypesFile.type,type/*wildcards includedextensionsFile.namefilenameMaxLengthFile.nameinfilenameCountUnitunitsFile.sizeof zeroThe sizes are formatted the way
FileValidatorformats 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, andImagewith its own geometry options is validated server side only.Documentation:
3_22.md.The fix is in the
svaroh/jsformvalidator-bundlepackage onmain. It is not backported tofp/jsformvalidator-bundle, which stays on its 1.x line, so upgrading to the new package is what picks it up.