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

Documented the detectCorrupted and corruptedMessage options #6433

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions reference/constraints/Image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of the documentation on this constraint.
| | - `allowSquare`_ |
| | - `allowLandscape`_ |
| | - `allowPortrait`_ |
| | - `detectCorrupted`_ |
| | - `mimeTypesMessage`_ |
| | - `sizeNotDetectedMessage`_ |
| | - `maxWidthMessage`_ |
Expand All @@ -35,6 +36,7 @@ of the documentation on this constraint.
| | - `allowSquareMessage`_ |
| | - `allowLandscapeMessage`_ |
| | - `allowPortraitMessage`_ |
| | - `corruptedMessage`_ |
| | - See :doc:`File </reference/constraints/File>` for inherited options |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Image` |
Expand Down Expand Up @@ -311,6 +313,18 @@ allowPortrait

If this option is false, the image cannot be portrait oriented.

detectCorrupted
~~~~~~~~~~~~~~~

.. versionadded:: 3.1
The ``detectCorrupted`` option was introduced in Symfony 3.1.

**type**: ``Boolean`` **default**: ``false``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean


If this option is true, the image contents are validated to ensure that the
image is not corrupted. This validation is done with PHP's ``imagecreatefromstring()``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the phpfunction role here.

function, which requires the PHP GD extension to be enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we link to the GD Extension?


sizeNotDetectedMessage
~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -392,4 +406,15 @@ Portrait oriented images are not allowed``

The error message if the image is portrait oriented and you set `allowPortrait`_ to ``false``.

corruptedMessage
~~~~~~~~~~~~~~~~

.. versionadded:: 3.1
The ``corruptedMessage`` option was introduced in Symfony 3.1.

**type**: ``string`` **default**: ``The image file is corrupted.``

The error message if the image contents are corrupted and you set `detectCorrupted`_
to ``true``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the order:

[...] when the detectCorrupted options is enabled and the image is corrupted.


.. _`IANA website`: http://www.iana.org/assignments/media-types/image/index.html