From e3acdc5dcfcf6419c0a784a8151b90067d01452e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sat, 31 May 2014 23:26:15 +0200 Subject: [PATCH 1/8] Support MaxSize in KiB and MiB --- reference/constraints/File.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 683d0fe6a49..7d200e4f36b 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -163,10 +163,16 @@ to be valid. The size of the file can be given in one of the following formats: numeric (e.g. ``4096``); * **kilobytes**: To specify the ``maxSize`` in kilobytes, pass a number and - suffix it with a lowercase "k" (e.g. ``200k``); + suffix it with a "k" (e.g. ``200k``); * **megabytes**: To specify the ``maxSize`` in megabytes, pass a number and - suffix it with a capital "M" (e.g. ``4M``). + suffix it with a "M" (e.g. ``4M``). + +* **kibibytes**: To specify the ``maxSize`` in kibibytes, pass a number and + suffix it with a "Ki" (e.g. ``600Ki``); + +* **mebibytes**: To specify the ``maxSize`` in mebibytes, pass a number and + suffix it with a "Mi" (e.g. ``8Mi``). mimeTypes ~~~~~~~~~ From deac0c3a6fd13c61eeca59d715c7fab014836f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 1 Jun 2014 15:33:56 +0200 Subject: [PATCH 2/8] Add option binaryFormat in constraint file --- reference/constraints/File.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 7d200e4f36b..a09c98a70d8 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -20,6 +20,7 @@ form type. | Applies to | :ref:`property or method ` | +----------------+---------------------------------------------------------------------+ | Options | - `maxSize`_ | +| | - `binaryFormat`_ | | | - `mimeTypes`_ | | | - `maxSizeMessage`_ | | | - `mimeTypesMessage`_ | @@ -78,7 +79,7 @@ below a certain file size and a valid PDF, add the following: maxSize: 1024k mimeTypes: [application/pdf, application/x-pdf] mimeTypesMessage: Please upload a valid PDF - + .. code-block:: php-annotations @@ -151,6 +152,18 @@ have been specified. Options ------- +.. versionadded:: 2.6 + The ``binaryFormat`` option was introduced in Symfony 2.6. + +binaryFormat +~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``null`` + +When true, the sizes will be displayed in messages with binary suffixes (KiB, MiB). +When false, the sizes will be displayed with SI suffixes (kB, MB). +When null, then the binaryFormat will be guessed from the suffix defined in the maxSize option. + maxSize ~~~~~~~ From 3f3f4e0292a80194e6c54d048feabef81a75c610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 1 Jun 2014 16:05:54 +0200 Subject: [PATCH 3/8] Provide information about SI and Binary prefixes --- reference/constraints/File.rst | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index a09c98a70d8..0c02b191097 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -164,6 +164,8 @@ When true, the sizes will be displayed in messages with binary suffixes (KiB, Mi When false, the sizes will be displayed with SI suffixes (kB, MB). When null, then the binaryFormat will be guessed from the suffix defined in the maxSize option. +For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. + maxSize ~~~~~~~ @@ -173,19 +175,21 @@ If set, the size of the underlying file must be below this file size in order to be valid. The size of the file can be given in one of the following formats: * **bytes**: To specify the ``maxSize`` in bytes, pass a value that is entirely - numeric (e.g. ``4096``); + numeric (e.g. ``4096``). * **kilobytes**: To specify the ``maxSize`` in kilobytes, pass a number and - suffix it with a "k" (e.g. ``200k``); + suffix it with a "k" (e.g. ``200k``); 1k = 1 000 bytes. * **megabytes**: To specify the ``maxSize`` in megabytes, pass a number and - suffix it with a "M" (e.g. ``4M``). + suffix it with a "M" (e.g. ``4M``); 1M = 1 000 000 bytes. * **kibibytes**: To specify the ``maxSize`` in kibibytes, pass a number and - suffix it with a "Ki" (e.g. ``600Ki``); + suffix it with a "Ki" (e.g. ``600Ki``); 1Ki = 1 024 bytes. * **mebibytes**: To specify the ``maxSize`` in mebibytes, pass a number and - suffix it with a "Mi" (e.g. ``8Mi``). + suffix it with a "Mi" (e.g. ``8Mi``); 1Mi = 1 048 576 bytes. + +For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. mimeTypes ~~~~~~~~~ @@ -257,3 +261,4 @@ to disk. .. _`IANA website`: http://www.iana.org/assignments/media-types/index.html +.. _`Wikipedia: Binary prefix`: http://en.wikipedia.org/wiki/Binary_prefix From 71fdd60f3c28521b4588f0908dedb1ce06f0d36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 1 Jun 2014 16:53:08 +0200 Subject: [PATCH 4/8] Fix line wrap --- reference/constraints/File.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 0c02b191097..cd573c3a7e3 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -160,11 +160,13 @@ binaryFormat **type**: ``boolean`` **default**: ``null`` -When true, the sizes will be displayed in messages with binary suffixes (KiB, MiB). -When false, the sizes will be displayed with SI suffixes (kB, MB). -When null, then the binaryFormat will be guessed from the suffix defined in the maxSize option. +When ``true``, the sizes will be displayed in messages with binary suffixes +(KiB, MiB). When ``false``, the sizes will be displayed with SI suffixes (kB, +MB). When ``null``, then the binaryFormat will be guessed from the suffix +defined in the maxSize option. -For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. +For more information about the difference between binary and SI suffixes, +see `Wikipedia: Binary prefix`_. maxSize ~~~~~~~ @@ -189,7 +191,8 @@ to be valid. The size of the file can be given in one of the following formats: * **mebibytes**: To specify the ``maxSize`` in mebibytes, pass a number and suffix it with a "Mi" (e.g. ``8Mi``); 1Mi = 1 048 576 bytes. -For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. +For more information about the difference between binary and SI suffixes, +see `Wikipedia: Binary prefix`_. mimeTypes ~~~~~~~~~ From 7dcd7c3b9b0d85be92a074f0dce8d28ae6fd7629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 1 Jun 2014 20:51:03 +0200 Subject: [PATCH 5/8] Move secion "binaryFormat" to the right place --- reference/constraints/File.rst | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index cd573c3a7e3..355901362b1 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -152,22 +152,6 @@ have been specified. Options ------- -.. versionadded:: 2.6 - The ``binaryFormat`` option was introduced in Symfony 2.6. - -binaryFormat -~~~~~~~~~~~~ - -**type**: ``boolean`` **default**: ``null`` - -When ``true``, the sizes will be displayed in messages with binary suffixes -(KiB, MiB). When ``false``, the sizes will be displayed with SI suffixes (kB, -MB). When ``null``, then the binaryFormat will be guessed from the suffix -defined in the maxSize option. - -For more information about the difference between binary and SI suffixes, -see `Wikipedia: Binary prefix`_. - maxSize ~~~~~~~ @@ -194,6 +178,22 @@ to be valid. The size of the file can be given in one of the following formats: For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. +binaryFormat +~~~~~~~~~~~~ + +.. versionadded:: 2.6 + The ``binaryFormat`` option was introduced in Symfony 2.6. + +**type**: ``boolean`` **default**: ``null`` + +When ``true``, the sizes will be displayed in messages with binary suffixes +(KiB, MiB). When ``false``, the sizes will be displayed with SI suffixes (kB, +MB). When ``null``, then the binaryFormat will be guessed from the suffix +defined in the maxSize option. + +For more information about the difference between binary and SI suffixes, +see `Wikipedia: Binary prefix`_. + mimeTypes ~~~~~~~~~ From b414f5c6e69cbad6a6c6a4d860f8144d0644650a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 19 Jun 2014 23:16:21 +0200 Subject: [PATCH 6/8] Use comma as thousands separator --- reference/constraints/File.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 355901362b1..6eb19e232af 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -80,7 +80,6 @@ below a certain file size and a valid PDF, add the following: mimeTypes: [application/pdf, application/x-pdf] mimeTypesMessage: Please upload a valid PDF - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -161,19 +160,19 @@ If set, the size of the underlying file must be below this file size in order to be valid. The size of the file can be given in one of the following formats: * **bytes**: To specify the ``maxSize`` in bytes, pass a value that is entirely - numeric (e.g. ``4096``). + numeric (e.g. ``4096``); * **kilobytes**: To specify the ``maxSize`` in kilobytes, pass a number and - suffix it with a "k" (e.g. ``200k``); 1k = 1 000 bytes. + suffix it with a "k" (e.g. ``200k``); 1k = 1,000 bytes; * **megabytes**: To specify the ``maxSize`` in megabytes, pass a number and - suffix it with a "M" (e.g. ``4M``); 1M = 1 000 000 bytes. + suffix it with a "M" (e.g. ``4M``); 1M = 1,000,000 bytes; * **kibibytes**: To specify the ``maxSize`` in kibibytes, pass a number and - suffix it with a "Ki" (e.g. ``600Ki``); 1Ki = 1 024 bytes. + suffix it with a "Ki" (e.g. ``600Ki``); 1Ki = 1,024 bytes; * **mebibytes**: To specify the ``maxSize`` in mebibytes, pass a number and - suffix it with a "Mi" (e.g. ``8Mi``); 1Mi = 1 048 576 bytes. + suffix it with a "Mi" (e.g. ``8Mi``); 1Mi = 1,048,576 bytes. For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. From 77a0687f3f2ca2a9aed57984d0fc0d73801317b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 24 Jun 2014 22:15:47 +0200 Subject: [PATCH 7/8] Add versionAdded on binary suffix --- reference/constraints/File.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 6eb19e232af..25edb10c8da 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -154,6 +154,9 @@ Options maxSize ~~~~~~~ +.. versionadded:: 2.6 + The suffixes ``Ki`` and ``Mi`` were introduced in Symfony 2.6. + **type**: ``mixed`` If set, the size of the underlying file must be below this file size in order @@ -188,7 +191,7 @@ binaryFormat When ``true``, the sizes will be displayed in messages with binary suffixes (KiB, MiB). When ``false``, the sizes will be displayed with SI suffixes (kB, MB). When ``null``, then the binaryFormat will be guessed from the suffix -defined in the maxSize option. +defined in the ``maxSize`` option. For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_. From 1e8fa48566091c10eb2ce40611e1909e6f73c9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 24 Jun 2014 22:17:51 +0200 Subject: [PATCH 8/8] Replace bullet list by a table --- reference/constraints/File.rst | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 25edb10c8da..686442cb365 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -162,20 +162,19 @@ maxSize If set, the size of the underlying file must be below this file size in order to be valid. The size of the file can be given in one of the following formats: -* **bytes**: To specify the ``maxSize`` in bytes, pass a value that is entirely - numeric (e.g. ``4096``); - -* **kilobytes**: To specify the ``maxSize`` in kilobytes, pass a number and - suffix it with a "k" (e.g. ``200k``); 1k = 1,000 bytes; - -* **megabytes**: To specify the ``maxSize`` in megabytes, pass a number and - suffix it with a "M" (e.g. ``4M``); 1M = 1,000,000 bytes; - -* **kibibytes**: To specify the ``maxSize`` in kibibytes, pass a number and - suffix it with a "Ki" (e.g. ``600Ki``); 1Ki = 1,024 bytes; - -* **mebibytes**: To specify the ``maxSize`` in mebibytes, pass a number and - suffix it with a "Mi" (e.g. ``8Mi``); 1Mi = 1,048,576 bytes. ++--------+-----------+-----------------+------+ +| Suffix | Unit Name | value | e.g. | ++========+===========+=================+======+ +| | byte | 1 byte | 4096 | ++--------+-----------+-----------------+------+ +| k | kilobyte | 1,000 bytes | 200k | ++--------+-----------+-----------------+------+ +| M | megabyte | 1,000,000 bytes | 2M | ++--------+-----------+-----------------+------+ +| Ki | kibibyte | 1,024 bytes | 32Ki | ++--------+-----------+-----------------+------+ +| Mi | mebibyte | 1,048,576 bytes | 8Mi | ++--------+-----------+-----------------+------+ For more information about the difference between binary and SI suffixes, see `Wikipedia: Binary prefix`_.