KnpGaufretteBundle icon indicating copy to clipboard operation
KnpGaufretteBundle copied to clipboard

Entity validation

Open LeighBicknell opened this issue 8 years ago • 1 comments

Good afternoon!

Unless I'm doing something wrong, it seems entity file validation doesn't appear to work out of the box?

     * @Assert\Image(
     *      minWidth = 200,
     *      minWidthMessage = "The image must be at least 200x200px",
     *      maxWidth = 20000,
     *      maxWidthMessage = "The image must be below 20,000x20,000px",
     *      minHeight = 200,
     *      minHeightMessage = "The image must be at least 200x200px",
     *      maxHeight = 20000,
     *      maxHeightMessage = "The image must be below 20,000x20,000px",
     *      sizeNotDetectedMessage = "Image size couldn't be detected",
     *      detectCorrupted = true,
     *      corruptedMessage = "The image is corrupt!"
     * )

The form fails validation with 'File not found' which makes sense as the path to the file stored in the entities property is simply '/{random}' by default.

Is there a way to make entity validation work?

LeighBicknell avatar Nov 10 '17 12:11 LeighBicknell

need to some how convert the path from gaufrette to a symfony file object, but this is more upload portion?

it should work out of the box when you use the symfony form to do upload/verification after which getting the data from the form to right to the fs, however if you are fetching path from database and do the verification after fetching, you need to convert that path into file object as mentioned above.

https://symfony.com/doc/current/reference/forms/types/file.html http://api.symfony.com/4.0/Symfony/Component/HttpFoundation/File/File.html

KoriSeng avatar Dec 14 '17 17:12 KoriSeng