Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 034e5b4

Browse filesBrowse files
committed
minor #5257 Let docbot review the constraint docs (WouterJ)
This PR was merged into the 2.3 branch. Discussion ---------- Let docbot review the constraint docs | Q | A | --- | --- | Doc fix? | yes, lots of them :) | New docs? | no | Applies to | 2.3+ | Fixed tickets | - Commits ------- 08178a5 Review other reference articles c765aa5 Let docbot review the constraint docs
2 parents 3ebe1b2 + 08178a5 commit 034e5b4
Copy full SHA for 034e5b4
Expand file treeCollapse file tree

38 files changed

+504
-412
lines changed

‎reference/constraints/All.rst

Copy file name to clipboardExpand all lines: reference/constraints/All.rst
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ All
44
When applied to an array (or Traversable object), this constraint allows
55
you to apply a collection of constraints to each element of the array.
66

7-
+----------------+------------------------------------------------------------------------+
8-
| Applies to | :ref:`property or method <validation-property-target>` |
9-
+----------------+------------------------------------------------------------------------+
10-
| Options | - `constraints`_ |
11-
+----------------+------------------------------------------------------------------------+
12-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
13-
+----------------+------------------------------------------------------------------------+
14-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` |
15-
+----------------+------------------------------------------------------------------------+
7+
+----------------+-------------------------------------------------------------------+
8+
| Applies to | :ref:`property or method <validation-property-target>` |
9+
+----------------+-------------------------------------------------------------------+
10+
| Options | - `constraints`_ |
11+
+----------------+-------------------------------------------------------------------+
12+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
13+
+----------------+-------------------------------------------------------------------+
14+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` |
15+
+----------------+-------------------------------------------------------------------+
1616

1717
Basic Usage
1818
-----------
1919

20-
Suppose that you have an array of strings, and you want to validate each
20+
Suppose that you have an array of strings and you want to validate each
2121
entry in that array:
2222

2323
.. configuration-block::

‎reference/constraints/Blank.rst

Copy file name to clipboardExpand all lines: reference/constraints/Blank.rst
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ Blank
33

44
Validates that a value is blank, defined as equal to a blank string or equal
55
to ``null``. To force that a value strictly be equal to ``null``, see the
6-
:doc:`/reference/constraints/Null` constraint. To force that a value is *not*
7-
blank, see :doc:`/reference/constraints/NotBlank`.
8-
9-
+----------------+-----------------------------------------------------------------------+
10-
| Applies to | :ref:`property or method <validation-property-target>` |
11-
+----------------+-----------------------------------------------------------------------+
12-
| Options | - `message`_ |
13-
+----------------+-----------------------------------------------------------------------+
14-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
15-
+----------------+-----------------------------------------------------------------------+
16-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` |
17-
+----------------+-----------------------------------------------------------------------+
6+
:doc:`/reference/constraints/Null` constraint. To force that a value is
7+
*not* blank, see :doc:`/reference/constraints/NotBlank`.
8+
9+
+----------------+---------------------------------------------------------------------+
10+
| Applies to | :ref:`property or method <validation-property-target>` |
11+
+----------------+---------------------------------------------------------------------+
12+
| Options | - `message`_ |
13+
+----------------+---------------------------------------------------------------------+
14+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
15+
+----------------+---------------------------------------------------------------------+
16+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` |
17+
+----------------+---------------------------------------------------------------------+
1818

1919
Basic Usage
2020
-----------

‎reference/constraints/Callback.rst

Copy file name to clipboardExpand all lines: reference/constraints/Callback.rst
+36-23Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Callback
22
========
33

44
The purpose of the Callback assertion is to let you create completely custom
5-
validation rules and to assign any validation errors to specific fields on
6-
your object. If you're using validation with forms, this means that you can
7-
make these custom errors display next to a specific field, instead of simply
8-
at the top of your form.
5+
validation rules and to assign any validation errors to specific fields
6+
on your object. If you're using validation with forms, this means that you
7+
can make these custom errors display next to a specific field, instead of
8+
simply at the top of your form.
99

1010
This process works by specifying one or more *callback* methods, each of
1111
which will be called during the validation process. Each of those methods
@@ -92,9 +92,9 @@ Setup
9292
The Callback Method
9393
-------------------
9494

95-
The callback method is passed a special ``ExecutionContextInterface`` object. You
96-
can set "violations" directly on this object and determine to which field
97-
those errors should be attributed::
95+
The callback method is passed a special ``ExecutionContextInterface`` object.
96+
You can set "violations" directly on this object and determine to which
97+
field those errors should be attributed::
9898

9999
// ...
100100
use Symfony\Component\Validator\ExecutionContextInterface;
@@ -111,7 +111,12 @@ those errors should be attributed::
111111

112112
// check if the name is actually a fake name
113113
if (in_array($this->getFirstName(), $fakeNames)) {
114-
$context->addViolationAt('firstname', 'This name sounds totally fake!', array(), null);
114+
$context->addViolationAt(
115+
'firstname',
116+
'This name sounds totally fake!',
117+
array(),
118+
null
119+
);
115120
}
116121
}
117122
}
@@ -129,9 +134,10 @@ process. Each method can be one of the following formats:
129134

130135
1) **String method name**
131136

132-
If the name of a method is a simple string (e.g. ``isAuthorValid``), that
133-
method will be called on the same object that's being validated and the
134-
``ExecutionContextInterface`` will be the only argument (see the above example).
137+
If the name of a method is a simple string (e.g. ``isAuthorValid``),
138+
that method will be called on the same object that's being validated
139+
and the ``ExecutionContextInterface`` will be the only argument (see
140+
the above example).
135141

136142
2) **Static array callback**
137143

@@ -197,15 +203,19 @@ process. Each method can be one of the following formats:
197203
{
198204
$metadata->addConstraint(new Callback(array(
199205
'methods' => array(
200-
array('Acme\BlogBundle\MyStaticValidatorClass', 'isAuthorValid'),
206+
array(
207+
'Acme\BlogBundle\MyStaticValidatorClass',
208+
'isAuthorValid',
209+
),
201210
),
202211
)));
203212
}
204213
}
205214
206-
In this case, the static method ``isAuthorValid`` will be called on the
207-
``Acme\BlogBundle\MyStaticValidatorClass`` class. It's passed both the original
208-
object being validated (e.g. ``Author``) as well as the ``ExecutionContextInterface``::
215+
In this case, the static method ``isAuthorValid`` will be called on
216+
the ``Acme\BlogBundle\MyStaticValidatorClass`` class. It's passed both
217+
the original object being validated (e.g. ``Author``) as well as the
218+
``ExecutionContextInterface``::
209219

210220
namespace Acme\BlogBundle;
211221

@@ -214,17 +224,20 @@ process. Each method can be one of the following formats:
214224

215225
class MyStaticValidatorClass
216226
{
217-
public static function isAuthorValid(Author $author, ExecutionContextInterface $context)
218-
{
227+
public static function isAuthorValid(
228+
Author $author,
229+
ExecutionContextInterface $context
230+
) {
219231
// ...
220232
}
221233
}
222234

223235
.. tip::
224236

225-
If you specify your ``Callback`` constraint via PHP, then you also have
226-
the option to make your callback either a PHP closure or a non-static
227-
callback. It is *not* currently possible, however, to specify a :term:`service`
228-
as a constraint. To validate using a service, you should
229-
:doc:`create a custom validation constraint </cookbook/validation/custom_constraint>`
230-
and add that new constraint to your class.
237+
If you specify your ``Callback`` constraint via PHP, then you also
238+
have the option to make your callback either a PHP closure or a
239+
non-static callback. It is *not* currently possible, however, to
240+
specify a :term:`service` as a constraint. To validate using a service,
241+
you should :doc:`create a custom validation constraint
242+
</cookbook/validation/custom_constraint>` and add that new constraint
243+
to your class.

‎reference/constraints/CardScheme.rst

Copy file name to clipboardExpand all lines: reference/constraints/CardScheme.rst
+12-8Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ CardScheme
44
.. versionadded:: 2.2
55
The ``CardScheme`` constraint was introduced in Symfony 2.2.
66

7-
This constraint ensures that a credit card number is valid for a given credit card
8-
company. It can be used to validate the number before trying to initiate a payment
9-
through a payment gateway.
7+
This constraint ensures that a credit card number is valid for a given credit
8+
card company. It can be used to validate the number before trying to initiate
9+
a payment through a payment gateway.
1010

1111
+----------------+--------------------------------------------------------------------------+
1212
| Applies to | :ref:`property or method <validation-property-target>` |
@@ -37,7 +37,10 @@ on an object that will contain a credit card number.
3737
class Transaction
3838
{
3939
/**
40-
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
40+
* @Assert\CardScheme(
41+
* schemes={"VISA"},
42+
* message="Your credit card number is invalid."
43+
* )
4144
*/
4245
protected $cardNumber;
4346
}
@@ -103,9 +106,9 @@ schemes
103106

104107
**type**: ``mixed`` [:ref:`default option <validation-default-option>`]
105108

106-
This option is required and represents the name of the number scheme used to
107-
validate the credit card number, it can either be a string or an array. Valid
108-
values are:
109+
This option is required and represents the name of the number scheme used
110+
to validate the credit card number, it can either be a string or an array.
111+
Valid values are:
109112

110113
* ``AMEX``
111114
* ``CHINA_UNIONPAY``
@@ -118,7 +121,8 @@ values are:
118121
* ``MASTERCARD``
119122
* ``VISA``
120123

121-
For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_.
124+
For more information about the used schemes, see
125+
`Wikipedia: Issuer identification number (IIN)`_.
122126

123127
message
124128
~~~~~~~

‎reference/constraints/Choice.rst

Copy file name to clipboardExpand all lines: reference/constraints/Choice.rst
+27-26Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ This constraint is used to ensure that the given value is one of a given
55
set of *valid* choices. It can also be used to validate that each item in
66
an array of items is one of those valid choices.
77

8-
+----------------+-----------------------------------------------------------------------+
9-
| Applies to | :ref:`property or method <validation-property-target>` |
10-
+----------------+-----------------------------------------------------------------------+
11-
| Options | - `choices`_ |
12-
| | - `callback`_ |
13-
| | - `multiple`_ |
14-
| | - `min`_ |
15-
| | - `max`_ |
16-
| | - `message`_ |
17-
| | - `multipleMessage`_ |
18-
| | - `minMessage`_ |
19-
| | - `maxMessage`_ |
20-
| | - `strict`_ |
21-
+----------------+-----------------------------------------------------------------------+
22-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
23-
+----------------+-----------------------------------------------------------------------+
24-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` |
25-
+----------------+-----------------------------------------------------------------------+
8+
+----------------+----------------------------------------------------------------------+
9+
| Applies to | :ref:`property or method <validation-property-target>` |
10+
+----------------+----------------------------------------------------------------------+
11+
| Options | - `choices`_ |
12+
| | - `callback`_ |
13+
| | - `multiple`_ |
14+
| | - `min`_ |
15+
| | - `max`_ |
16+
| | - `message`_ |
17+
| | - `multipleMessage`_ |
18+
| | - `minMessage`_ |
19+
| | - `maxMessage`_ |
20+
| | - `strict`_ |
21+
+----------------+----------------------------------------------------------------------+
22+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
23+
+----------------+----------------------------------------------------------------------+
24+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` |
25+
+----------------+----------------------------------------------------------------------+
2626

2727
Basic Usage
2828
-----------
@@ -275,8 +275,8 @@ callback
275275
**type**: ``string|array|Closure``
276276

277277
This is a callback method that can be used instead of the `choices`_ option
278-
to return the choices array. See `Supplying the Choices with a Callback Function`_
279-
for details on its usage.
278+
to return the choices array. See
279+
`Supplying the Choices with a Callback Function`_ for details on its usage.
280280

281281
multiple
282282
~~~~~~~~
@@ -313,16 +313,17 @@ message
313313

314314
**type**: ``string`` **default**: ``The value you selected is not a valid choice.``
315315

316-
This is the message that you will receive if the ``multiple`` option is set
317-
to ``false``, and the underlying value is not in the valid array of choices.
316+
This is the message that you will receive if the ``multiple`` option is
317+
set to ``false`` and the underlying value is not in the valid array of
318+
choices.
318319

319320
multipleMessage
320321
~~~~~~~~~~~~~~~
321322

322323
**type**: ``string`` **default**: ``One or more of the given values is invalid.``
323324

324-
This is the message that you will receive if the ``multiple`` option is set
325-
to ``true``, and one of the values on the underlying array being checked
325+
This is the message that you will receive if the ``multiple`` option is
326+
set to ``true`` and one of the values on the underlying array being checked
326327
is not in the array of valid choices.
327328

328329
minMessage
@@ -347,5 +348,5 @@ strict
347348
**type**: ``Boolean`` **default**: ``false``
348349

349350
If true, the validator will also check the type of the input value. Specifically,
350-
this value is passed to as the third argument to the PHP :phpfunction:`in_array` method
351-
when checking to see if a value is in the valid choices array.
351+
this value is passed to as the third argument to the PHP :phpfunction:`in_array`
352+
method when checking to see if a value is in the valid choices array.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.