http://symfony.com/doc/3.2/components/validator/resources.html
Example of usage of @Assert\File
/**
* @var \SplFileInfo
*
* @Assert\File(
* mimeTypes = {"application/x-bittorrent"},
* mimeTypesMessage = "Your file was not recognize as a .torrent file.",
* maxSize = "100k",
* maxSizeMessage = "Your .torrent file was rejected because it is too large.",
* disallowEmptyMessage = "The uploaded torrent file seems completely empty.",
* uploadIniSizeErrorMessage = "Your torrent file was rejected because it is too big (limited by server). {{ limit }}{{ suffix }} max allowed.",
* groups={"default", "torrent_menu"}
* )
*/
protected $uploadedFileByUrl = null;
and official docs: https://symfony.com/doc/3.2/reference/constraints/File.html#maxsize
validation groups example:
https://symfony.com/doc/3.2/form/data_based_validation.html
When one want a different validation for the same form (different for when the "Product" is first created, and different when it is edited, but we're using here the same form)
"Suppose now, that you don’t want the user to be able to change the name value once the object has been created. To do this, you can rely on Symfony’s Event Dispatcher system to analyze the data on the object and modify the form based on the Product object’s data. In this entry, you’ll learn how to add this level of flexibility to your forms."
http://symfony2-document.readthedocs.io/en/latest/cookbook/form/dynamic_form_generation.html