Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity validation #170

Open
LeighBicknell opened this issue Nov 10, 2017 · 1 comment
Open

Entity validation #170

LeighBicknell opened this issue Nov 10, 2017 · 1 comment
Assignees

Comments

@LeighBicknell
Copy link

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?

@KoriSeng
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants