Skip to content

Added documentation for validator message variables in File constraints #10584

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

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
110 changes: 108 additions & 2 deletions reference/constraints/File.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,21 @@ maxSizeMessage

The message displayed if the file is larger than the `maxSize`_ option.

You can use the following parameters in this message:
+------------------+------------------------------------------------+
| Parameter | Description |
+==================+================================================+
| ``{{ size }}`` | File size of the file |
+------------------+------------------------------------------------+
| ``{{ limit }}`` | Maximum file size allowed |
+------------------+------------------------------------------------+
| ``{{ suffix }}`` | Suffix for the used file size unit (see above) |
+------------------+------------------------------------------------+
| ``{{ file }}`` | Full file path |
+------------------+------------------------------------------------+
| ``{{ name }}`` | Base file name |
+------------------+------------------------------------------------+

mimeTypesMessage
~~~~~~~~~~~~~~~~

Expand All @@ -220,6 +235,19 @@ mimeTypesMessage
The message displayed if the mime type of the file is not a valid mime type
per the `mimeTypes`_ option.

You can use the following parameters in this message:
+-----------------+----------------------------------------+
| Parameter | Description |
+=================+========================================+
| ``{{ type }}`` | The (disallowed) mime type of the file |
+-----------------+----------------------------------------+
| ``{{ types }}`` | The list of allowed mime types |
+-----------------+----------------------------------------+
| ``{{ file }}`` | Full file path |
+-----------------+----------------------------------------+
| ``{{ name }}`` | Base file name |
+-----------------+----------------------------------------+

disallowEmptyMessage
~~~~~~~~~~~~~~~~~~~~

Expand All @@ -228,6 +256,15 @@ disallowEmptyMessage
This constraint checks if the uploaded file is empty (i.e. 0 bytes). If it is,
this message is displayed.

You can use the following parameters in this message:
+----------------+----------------+
| Parameter | Description |
+================+================+
| ``{{ file }}`` | Full file path |
+----------------+----------------+
| ``{{ name }}`` | Base file name |
+----------------+----------------+

notFoundMessage
~~~~~~~~~~~~~~~

Expand All @@ -237,6 +274,13 @@ The message displayed if no file can be found at the given path. This error
is only likely if the underlying value is a string path, as a ``File`` object
cannot be constructed with an invalid file path.

You can use the following parameters in this message:
+----------------+----------------+
| Parameter | Description |
+================+================+
| ``{{ file }}`` | Full file path |
+----------------+----------------+

notReadableMessage
~~~~~~~~~~~~~~~~~~

Expand All @@ -245,6 +289,13 @@ notReadableMessage
The message displayed if the file exists, but the PHP ``is_readable()`` function
fails when passed the path to the file.

You can use the following parameters in this message:
+----------------+----------------+
| Parameter | Description |
+================+================+
| ``{{ file }}`` | Full file path |
+----------------+----------------+

uploadIniSizeErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -253,6 +304,15 @@ uploadIniSizeErrorMessage
The message that is displayed if the uploaded file is larger than the ``upload_max_filesize``
``php.ini`` setting.

You can use the following parameters in this message:
+------------------+------------------------------------------------+
| Parameter | Description |
+==================+================================================+
| ``{{ limit }}`` | Maximum file size allowed |
+------------------+------------------------------------------------+
| ``{{ suffix }}`` | Suffix for the used file size unit (see above) |
+------------------+------------------------------------------------+

uploadFormSizeErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -261,14 +321,60 @@ uploadFormSizeErrorMessage
The message that is displayed if the uploaded file is larger than allowed
by the HTML file input field.

This message has no parameters.

uploadPartialErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~~
**type**: ``string`` **default**: ``The file was only partially uploaded.``

The message that is displayed if the uploaded file is only partially uploaded.

This message has no parameters.

uploadNoFileErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~
**type**: ``string`` **default**: ``No file was uploaded.``

The message that is displayed if no file was uploaded.

This message has no parameters.

uploadNoTmpDirErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~~~
**type**: ``string`` **default**: ``No temporary folder was configured in php.ini.``

The message that is displayed if the php.ini setting ``upload_tmp_dir`` is
missing.

This message has no parameters.

uploadCantWriteErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~~~~
**type**: ``string`` **default**: ``Cannot write temporary file to disk.``

The message that is displayed if the uploaded file can't be stored in the
temporary folder.

This message has no parameters.

uploadExtensionErrorMessage
~~~~~~~~~~~~~~~~~~~~~~~~~~~
**type**: ``string`` **default**: ``A PHP extension caused the upload to fail.``

The message that is displayed if a PHP extension caused the file upload to
fail.

This message has no parameters.

uploadErrorMessage
~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``The file could not be uploaded.``

The message that is displayed if the uploaded file could not be uploaded
for some unknown reason, such as the file upload failed or it couldn't be
written to disk.
for some unknown reason.

This message has no parameters.

.. include:: /reference/constraints/_payload-option.rst.inc

Expand Down