Skip to content

Commit da9aa0e

Browse files
committed
Added the docs for the \"groups\" constraint option
1 parent d873d06 commit da9aa0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+184
-39
lines changed

reference/constraints/All.rst

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ you to apply a collection of constraints to each element of the array.
88
| Applies to | :ref:`property or method <validation-property-target>` |
99
+----------------+-------------------------------------------------------------------+
1010
| Options | - `constraints`_ |
11+
| | - `groups`_ |
1112
| | - `payload`_ |
1213
+----------------+-------------------------------------------------------------------+
1314
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
@@ -109,4 +110,6 @@ constraints
109110
This required option is the array of validation constraints that you want
110111
to apply to each element of the underlying array.
111112

113+
.. include:: /reference/constraints/_groups-option.rst.inc
114+
112115
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Bic.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ uniquely identify both financial and non-financial institutions.
88
+----------------+-----------------------------------------------------------------------+
99
| Applies to | :ref:`property or method <validation-property-target>` |
1010
+----------------+-----------------------------------------------------------------------+
11-
| Options | - `message`_ |
11+
| Options | - `groups`_ |
12+
| | - `message`_ |
1213
| | - `payload`_ |
1314
+----------------+-----------------------------------------------------------------------+
1415
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Bic` |
@@ -85,6 +86,8 @@ will contain a Business Identifier Code (BIC).
8586
Available Options
8687
-----------------
8788

89+
.. include:: /reference/constraints/_groups-option.rst.inc
90+
8891
message
8992
~~~~~~~
9093

reference/constraints/Blank.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ But be careful as ``NotBlank`` is *not* strictly the opposite of ``Blank``.
1616
+----------------+---------------------------------------------------------------------+
1717
| Applies to | :ref:`property or method <validation-property-target>` |
1818
+----------------+---------------------------------------------------------------------+
19-
| Options | - `message`_ |
19+
| Options | - `groups`_ |
20+
| | - `message`_ |
2021
| | - `payload`_ |
2122
+----------------+---------------------------------------------------------------------+
2223
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
@@ -89,6 +90,8 @@ of an ``Author`` class were blank, you could do the following:
8990
Options
9091
-------
9192

93+
.. include:: /reference/constraints/_groups-option.rst.inc
94+
9295
message
9396
~~~~~~~
9497

reference/constraints/Callback.rst

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ can do anything, including creating and assigning validation errors.
2121
| Applies to | :ref:`class <validation-class-target>` |
2222
+----------------+------------------------------------------------------------------------+
2323
| Options | - :ref:`callback <callback-option>` |
24+
| | - `groups`_ |
2425
| | - `payload`_ |
2526
+----------------+------------------------------------------------------------------------+
2627
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Callback` |
@@ -275,4 +276,6 @@ Static or closure callbacks receive the validated object as the first argument
275276
and the :class:`Symfony\\Component\\Validator\\Context\\ExecutionContextInterface`
276277
instance as the second argument.
277278

279+
.. include:: /reference/constraints/_groups-option.rst.inc
280+
278281
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/CardScheme.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ a payment through a payment gateway.
88
+----------------+--------------------------------------------------------------------------+
99
| Applies to | :ref:`property or method <validation-property-target>` |
1010
+----------------+--------------------------------------------------------------------------+
11-
| Options | - `schemes`_ |
11+
| Options | - `groups`_ |
12+
| | - `schemes`_ |
1213
| | - `message`_ |
1314
| | - `payload`_ |
1415
+----------------+--------------------------------------------------------------------------+
@@ -101,6 +102,8 @@ on an object that will contain a credit card number.
101102
Available Options
102103
-----------------
103104

105+
.. include:: /reference/constraints/_groups-option.rst.inc
106+
104107
schemes
105108
~~~~~~~
106109

reference/constraints/Choice.rst

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ an array of items is one of those valid choices.
1010
+----------------+----------------------------------------------------------------------+
1111
| Options | - `choices`_ |
1212
| | - `callback`_ |
13+
| | - `groups`_ |
1314
| | - `multiple`_ |
1415
| | - `min`_ |
1516
| | - `max`_ |
@@ -300,6 +301,8 @@ This is a callback method that can be used instead of the `choices`_ option
300301
to return the choices array. See
301302
`Supplying the Choices with a Callback Function`_ for details on its usage.
302303

304+
.. include:: /reference/constraints/_groups-option.rst.inc
305+
303306
multiple
304307
~~~~~~~~
305308

reference/constraints/Collection.rst

+22-19
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ and that extra keys are not present.
1414
+----------------+--------------------------------------------------------------------------+
1515
| Applies to | :ref:`property or method <validation-property-target>` |
1616
+----------------+--------------------------------------------------------------------------+
17-
| Options | - `fields`_ |
18-
| | - `allowExtraFields`_ |
19-
| | - `extraFieldsMessage`_ |
17+
| Options | - `allowExtraFields`_ |
2018
| | - `allowMissingFields`_ |
19+
| | - `extraFieldsMessage`_ |
20+
| | - `fields`_ |
21+
| | - `groups`_ |
2122
| | - `missingFieldsMessage`_ |
2223
| | - `payload`_ |
2324
+----------------+--------------------------------------------------------------------------+
@@ -289,15 +290,6 @@ the ``NotBlank`` constraint will still be applied (since it is wrapped in
289290
Options
290291
-------
291292

292-
fields
293-
~~~~~~
294-
295-
**type**: ``array`` [:ref:`default option <validation-default-option>`]
296-
297-
This option is required and is an associative array defining all of the
298-
keys in the collection and, for each key, exactly which validator(s) should
299-
be executed against that element of the collection.
300-
301293
allowExtraFields
302294
~~~~~~~~~~~~~~~~
303295

@@ -307,6 +299,16 @@ If this option is set to ``false`` and the underlying collection contains
307299
one or more elements that are not included in the `fields`_ option, a validation
308300
error will be returned. If set to ``true``, extra fields are ok.
309301

302+
allowMissingFields
303+
~~~~~~~~~~~~~~~~~~
304+
305+
**type**: ``boolean`` **default**: false
306+
307+
If this option is set to ``false`` and one or more fields from the `fields`_
308+
option are not present in the underlying collection, a validation error
309+
will be returned. If set to ``true``, it's ok if some fields in the `fields`_
310+
option are not present in the underlying collection.
311+
310312
extraFieldsMessage
311313
~~~~~~~~~~~~~~~~~~
312314

@@ -323,15 +325,16 @@ You can use the following parameters in this message:
323325
| ``{{ field }}`` | The key of the extra field detected |
324326
+------------------+------------------------------------------------+
325327

326-
allowMissingFields
327-
~~~~~~~~~~~~~~~~~~
328+
fields
329+
~~~~~~
328330

329-
**type**: ``boolean`` **default**: false
331+
**type**: ``array`` [:ref:`default option <validation-default-option>`]
330332

331-
If this option is set to ``false`` and one or more fields from the `fields`_
332-
option are not present in the underlying collection, a validation error
333-
will be returned. If set to ``true``, it's ok if some fields in the `fields`_
334-
option are not present in the underlying collection.
333+
This option is required and is an associative array defining all of the
334+
keys in the collection and, for each key, exactly which validator(s) should
335+
be executed against that element of the collection.
336+
337+
.. include:: /reference/constraints/_groups-option.rst.inc
335338

336339
missingFieldsMessage
337340
~~~~~~~~~~~~~~~~~~~~

reference/constraints/Count.rst

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Countable) element count is *between* some minimum and maximum value.
1313
| | - `maxMessage`_ |
1414
| | - `exactMessage`_ |
1515
| | - `payload`_ |
16+
| | - `groups`_ |
1617
+----------------+---------------------------------------------------------------------+
1718
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Count` |
1819
+----------------+---------------------------------------------------------------------+
@@ -103,6 +104,8 @@ you might add the following:
103104
Options
104105
-------
105106

107+
.. include:: /reference/constraints/_groups-option.rst.inc
108+
106109
min
107110
~~~
108111

reference/constraints/Country.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Validates that a value is a valid `ISO 3166-1 alpha-2`_ country code.
66
+----------------+------------------------------------------------------------------------+
77
| Applies to | :ref:`property or method <validation-property-target>` |
88
+----------------+------------------------------------------------------------------------+
9-
| Options | - `message`_ |
9+
| Options | - `groups`_ |
10+
| | - `message`_ |
1011
| | - `payload`_ |
1112
+----------------+------------------------------------------------------------------------+
1213
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Country` |
@@ -78,6 +79,8 @@ Basic Usage
7879
Options
7980
-------
8081

82+
.. include:: /reference/constraints/_groups-option.rst.inc
83+
8184
message
8285
~~~~~~~
8386

reference/constraints/Currency.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Validates that a value is a valid `3-letter ISO 4217`_ currency name.
66
+----------------+---------------------------------------------------------------------------+
77
| Applies to | :ref:`property or method<validation-property-target>` |
88
+----------------+---------------------------------------------------------------------------+
9-
| Options | - `message`_ |
9+
| Options | - `groups`_ |
10+
| | - `message`_ |
1011
| | - `payload`_ |
1112
+----------------+---------------------------------------------------------------------------+
1213
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Currency` |
@@ -81,6 +82,8 @@ a valid currency, you could do the following:
8182
Options
8283
-------
8384

85+
.. include:: /reference/constraints/_groups-option.rst.inc
86+
8487
message
8588
~~~~~~~
8689

reference/constraints/Date.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ valid YYYY-MM-DD format.
88
+----------------+--------------------------------------------------------------------+
99
| Applies to | :ref:`property or method <validation-property-target>` |
1010
+----------------+--------------------------------------------------------------------+
11-
| Options | - `message`_ |
11+
| Options | - `groups`_ |
12+
| | - `message`_ |
1213
| | - `payload`_ |
1314
+----------------+--------------------------------------------------------------------+
1415
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Date` |
@@ -80,6 +81,8 @@ Basic Usage
8081
Options
8182
-------
8283

84+
.. include:: /reference/constraints/_groups-option.rst.inc
85+
8386
message
8487
~~~~~~~
8588

reference/constraints/DateTime.rst

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ a specific format.
99
| Applies to | :ref:`property or method <validation-property-target>` |
1010
+----------------+------------------------------------------------------------------------+
1111
| Options | - `format`_ |
12+
| | - `groups`_ |
1213
| | - `message`_ |
1314
| | - `payload`_ |
1415
+----------------+------------------------------------------------------------------------+
@@ -89,6 +90,8 @@ format
8990
This option allows to validate a custom date format. See
9091
:phpmethod:`DateTime::createFromFormat` for formatting options.
9192

93+
.. include:: /reference/constraints/_groups-option.rst.inc
94+
9295
message
9396
~~~~~~~
9497

reference/constraints/Email.rst

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cast to a string before being validated.
1212
| | - `checkMX`_ |
1313
| | - `checkHost`_ |
1414
| | - `payload`_ |
15+
| | - `groups`_ |
1516
+----------------+---------------------------------------------------------------------+
1617
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Email` |
1718
+----------------+---------------------------------------------------------------------+
@@ -93,6 +94,8 @@ Basic Usage
9394
Options
9495
-------
9596

97+
.. include:: /reference/constraints/_groups-option.rst.inc
98+
9699
strict
97100
~~~~~~
98101

reference/constraints/EqualTo.rst

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ To force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualT
1414
| Applies to | :ref:`property or method<validation-property-target>` |
1515
+----------------+-----------------------------------------------------------------------+
1616
| Options | - `value`_ |
17+
| | - `groups`_ |
1718
| | - `message`_ |
1819
| | - `payload`_ |
1920
| | - `propertyPath`_ |
@@ -111,6 +112,8 @@ Options
111112

112113
.. include:: /reference/constraints/_comparison-value-option.rst.inc
113114

115+
.. include:: /reference/constraints/_groups-option.rst.inc
116+
114117
message
115118
~~~~~~~
116119

reference/constraints/Expression.rst

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gives you similar flexibility.
1010
| Applies to | :ref:`class <validation-class-target>` or :ref:`property/method <validation-property-target>` |
1111
+----------------+-----------------------------------------------------------------------------------------------+
1212
| Options | - :ref:`expression <reference-constraint-expression-option>` |
13+
| | - `groups`_ |
1314
| | - `message`_ |
1415
| | - `payload`_ |
1516
+----------------+-----------------------------------------------------------------------------------------------+
@@ -245,6 +246,8 @@ in your expression:
245246
* ``value``: The value of the property being validated (only available when
246247
the constraint is applied directly to a property);
247248

249+
.. include:: /reference/constraints/_groups-option.rst.inc
250+
248251
message
249252
~~~~~~~
250253

reference/constraints/File.rst

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ form field.
3636
| | - `uploadExtensionErrorMessage`_ |
3737
| | - `uploadErrorMessage`_ |
3838
| | - `payload`_ |
39+
| | - `groups`_ |
3940
+----------------+---------------------------------------------------------------------+
4041
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\File` |
4142
+----------------+---------------------------------------------------------------------+
@@ -388,5 +389,7 @@ This message has no parameters.
388389

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

392+
.. include:: /reference/constraints/_groups-option.rst.inc
393+
391394
.. _`IANA website`: http://www.iana.org/assignments/media-types/index.html
392395
.. _`Wikipedia: Binary prefix`: http://en.wikipedia.org/wiki/Binary_prefix

reference/constraints/GreaterThan.rst

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ than another value, see :doc:`/reference/constraints/LessThan`.
1010
| Applies to | :ref:`property or method<validation-property-target>` |
1111
+----------------+---------------------------------------------------------------------------+
1212
| Options | - `value`_ |
13+
| | - `groups`_ |
1314
| | - `message`_ |
1415
| | - `payload`_ |
1516
| | - `propertyPath`_ |
@@ -292,6 +293,8 @@ Options
292293

293294
.. include:: /reference/constraints/_comparison-value-option.rst.inc
294295

296+
.. include:: /reference/constraints/_groups-option.rst.inc
297+
295298
message
296299
~~~~~~~
297300

0 commit comments

Comments
 (0)