Skip to content

Added the docs for the "groups" constraint option #11092

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 3 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions reference/constraints/All.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ you to apply a collection of constraints to each element of the array.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+-------------------------------------------------------------------+
| Options | - `constraints`_ |
| | - `groups`_ |
| | - `payload`_ |
+----------------+-------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
Expand Down Expand Up @@ -109,4 +110,6 @@ constraints
This required option is the array of validation constraints that you want
to apply to each element of the underlying array.

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

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 4 additions & 1 deletion reference/constraints/Bic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ uniquely identify both financial and non-financial institutions.
+----------------+-----------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+-----------------------------------------------------------------------+
| Options | - `message`_ |
| Options | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Bic` |
Expand Down Expand Up @@ -85,6 +86,8 @@ will contain a Business Identifier Code (BIC).
Available Options
-----------------

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

message
~~~~~~~

Expand Down
5 changes: 4 additions & 1 deletion reference/constraints/Blank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ But be careful as ``NotBlank`` is *not* strictly the opposite of ``Blank``.
+----------------+---------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+---------------------------------------------------------------------+
| Options | - `message`_ |
| Options | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
Expand Down Expand Up @@ -89,6 +90,8 @@ of an ``Author`` class were blank, you could do the following:
Options
-------

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

message
~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ can do anything, including creating and assigning validation errors.
| Applies to | :ref:`class <validation-class-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - :ref:`callback <callback-option>` |
| | - `groups`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Callback` |
Expand Down Expand Up @@ -275,4 +276,6 @@ Static or closure callbacks receive the validated object as the first argument
and the :class:`Symfony\\Component\\Validator\\Context\\ExecutionContextInterface`
instance as the second argument.

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

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 4 additions & 1 deletion reference/constraints/CardScheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ a payment through a payment gateway.
+----------------+--------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+--------------------------------------------------------------------------+
| Options | - `schemes`_ |
| Options | - `groups`_ |
| | - `schemes`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+--------------------------------------------------------------------------+
Expand Down Expand Up @@ -101,6 +102,8 @@ on an object that will contain a credit card number.
Available Options
-----------------

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

schemes
~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/Choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ an array of items is one of those valid choices.
+----------------+----------------------------------------------------------------------+
| Options | - `choices`_ |
| | - `callback`_ |
| | - `groups`_ |
| | - `multiple`_ |
| | - `min`_ |
| | - `max`_ |
Expand Down Expand Up @@ -300,6 +301,8 @@ This is a callback method that can be used instead of the `choices`_ option
to return the choices array. See
`Supplying the Choices with a Callback Function`_ for details on its usage.

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

multiple
~~~~~~~~

Expand Down
41 changes: 22 additions & 19 deletions reference/constraints/Collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ and that extra keys are not present.
+----------------+--------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+--------------------------------------------------------------------------+
| Options | - `fields`_ |
| | - `allowExtraFields`_ |
| | - `extraFieldsMessage`_ |
| Options | - `allowExtraFields`_ |
| | - `allowMissingFields`_ |
| | - `extraFieldsMessage`_ |
| | - `fields`_ |
| | - `groups`_ |
| | - `missingFieldsMessage`_ |
| | - `payload`_ |
+----------------+--------------------------------------------------------------------------+
Expand Down Expand Up @@ -289,15 +290,6 @@ the ``NotBlank`` constraint will still be applied (since it is wrapped in
Options
-------

fields
~~~~~~

**type**: ``array`` [:ref:`default option <validation-default-option>`]

This option is required and is an associative array defining all of the
keys in the collection and, for each key, exactly which validator(s) should
be executed against that element of the collection.

allowExtraFields
~~~~~~~~~~~~~~~~

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

allowMissingFields
~~~~~~~~~~~~~~~~~~

**type**: ``boolean`` **default**: false

If this option is set to ``false`` and one or more fields from the `fields`_
option are not present in the underlying collection, a validation error
will be returned. If set to ``true``, it's ok if some fields in the `fields`_
option are not present in the underlying collection.

extraFieldsMessage
~~~~~~~~~~~~~~~~~~

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

allowMissingFields
~~~~~~~~~~~~~~~~~~
fields
~~~~~~

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

If this option is set to ``false`` and one or more fields from the `fields`_
option are not present in the underlying collection, a validation error
will be returned. If set to ``true``, it's ok if some fields in the `fields`_
option are not present in the underlying collection.
This option is required and is an associative array defining all of the
keys in the collection and, for each key, exactly which validator(s) should
be executed against that element of the collection.

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

missingFieldsMessage
~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/Count.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Countable) element count is *between* some minimum and maximum value.
| | - `maxMessage`_ |
| | - `exactMessage`_ |
| | - `payload`_ |
| | - `groups`_ |
Copy link
Contributor

Choose a reason for hiding this comment

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

Same and below

+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Count` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -103,6 +104,8 @@ you might add the following:
Options
-------

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

min
~~~

Expand Down
5 changes: 4 additions & 1 deletion reference/constraints/Country.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Validates that a value is a valid `ISO 3166-1 alpha-2`_ country code.
+----------------+------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `message`_ |
| Options | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Country` |
Expand Down Expand Up @@ -78,6 +79,8 @@ Basic Usage
Options
-------

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

message
~~~~~~~

Expand Down
5 changes: 4 additions & 1 deletion reference/constraints/Currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Validates that a value is a valid `3-letter ISO 4217`_ currency name.
+----------------+---------------------------------------------------------------------------+
| Applies to | :ref:`property or method<validation-property-target>` |
+----------------+---------------------------------------------------------------------------+
| Options | - `message`_ |
| Options | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Currency` |
Expand Down Expand Up @@ -81,6 +82,8 @@ a valid currency, you could do the following:
Options
-------

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

message
~~~~~~~

Expand Down
5 changes: 4 additions & 1 deletion reference/constraints/Date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ valid YYYY-MM-DD format.
+----------------+--------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+--------------------------------------------------------------------+
| Options | - `message`_ |
| Options | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+--------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Date` |
Expand Down Expand Up @@ -80,6 +81,8 @@ Basic Usage
Options
-------

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

message
~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/DateTime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ a specific format.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `format`_ |
| | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -89,6 +90,8 @@ format
This option allows to validate a custom date format. See
:phpmethod:`DateTime::createFromFormat` for formatting options.

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

message
~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/Email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cast to a string before being validated.
| | - `checkMX`_ |
| | - `checkHost`_ |
| | - `payload`_ |
| | - `groups`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Email` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -93,6 +94,8 @@ Basic Usage
Options
-------

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

strict
~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/EqualTo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualT
| Applies to | :ref:`property or method<validation-property-target>` |
+----------------+-----------------------------------------------------------------------+
| Options | - `value`_ |
| | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
| | - `propertyPath`_ |
Expand Down Expand Up @@ -111,6 +112,8 @@ Options

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

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

message
~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/Expression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gives you similar flexibility.
| Applies to | :ref:`class <validation-class-target>` or :ref:`property/method <validation-property-target>` |
+----------------+-----------------------------------------------------------------------------------------------+
| Options | - :ref:`expression <reference-constraint-expression-option>` |
| | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -245,6 +246,8 @@ in your expression:
* ``value``: The value of the property being validated (only available when
the constraint is applied directly to a property);

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

message
~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions reference/constraints/File.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ form field.
| | - `uploadExtensionErrorMessage`_ |
| | - `uploadErrorMessage`_ |
| | - `payload`_ |
| | - `groups`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\File` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -388,5 +389,7 @@ This message has no parameters.

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

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

.. _`IANA website`: http://www.iana.org/assignments/media-types/index.html
.. _`Wikipedia: Binary prefix`: http://en.wikipedia.org/wiki/Binary_prefix
3 changes: 3 additions & 0 deletions reference/constraints/GreaterThan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ than another value, see :doc:`/reference/constraints/LessThan`.
| Applies to | :ref:`property or method<validation-property-target>` |
+----------------+---------------------------------------------------------------------------+
| Options | - `value`_ |
| | - `groups`_ |
| | - `message`_ |
| | - `payload`_ |
| | - `propertyPath`_ |
Expand Down Expand Up @@ -292,6 +293,8 @@ Options

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

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

message
~~~~~~~

Expand Down
Loading