Skip to content

Commit 1f89237

Browse files
committed
Merge branch '4.2'
* 4.2: streamline the constraints reference
2 parents 9f2bb54 + b14c33c commit 1f89237

29 files changed

+57
-71
lines changed

reference/constraints/All.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ entry in that array:
3636
* @Assert\Length(min=5)
3737
* })
3838
*/
39-
protected $favoriteColors = [];
39+
protected $favoriteColors = [];
4040
}
4141
4242
.. code-block:: yaml

reference/constraints/Bic.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ will contain a Business Identifier Code (BIC).
7474
7575
class Transaction
7676
{
77-
protected $businessIdentifierCode;
78-
7977
public static function loadValidatorMetadata(ClassMetadata $metadata)
8078
{
8179
$metadata->addPropertyConstraint('businessIdentifierCode', new Assert\Bic());

reference/constraints/Callback.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ Configuration
8484
{
8585
$metadata->addConstraint(new Assert\Callback('validate'));
8686
}
87+
88+
public function validate(ExecutionContextInterface $context, $payload)
89+
{
90+
// ...
91+
}
8792
}
8893
8994
The Callback Method

reference/constraints/CardScheme.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ on an object that will contain a credit card number.
8181
8282
class Transaction
8383
{
84-
protected $cardNumber;
85-
8684
public static function loadValidatorMetadata(ClassMetadata $metadata)
8785
{
8886
$metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme([

reference/constraints/Choice.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ If your valid choice list is simple, you can pass them in directly via the
108108
109109
class Author
110110
{
111-
protected $genre;
112-
113111
public static function loadValidatorMetadata(ClassMetadata $metadata)
114112
{
115113
$metadata->addPropertyConstraint(

reference/constraints/Collection.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ following:
143143
144144
class Author
145145
{
146-
private $options = [];
147-
148146
public static function loadValidatorMetadata(ClassMetadata $metadata)
149147
{
150148
$metadata->addPropertyConstraint('profileData', new Assert\Collection([
@@ -210,7 +208,7 @@ you can do the following:
210208
* }
211209
* )
212210
*/
213-
protected $profileData = ['personal_email'];
211+
protected $profileData = ['personal_email'];
214212
}
215213
216214
.. code-block:: yaml
@@ -274,9 +272,10 @@ you can do the following:
274272
{
275273
$metadata->addPropertyConstraint('profileData', new Assert\Collection([
276274
'fields' => [
277-
'personal_email' => new Assert\Required(
278-
[new Assert\NotBlank(), new Assert\Email()]
279-
),
275+
'personal_email' => new Assert\Required([
276+
new Assert\NotBlank(),
277+
new Assert\Email(),
278+
]),
280279
'alternate_email' => new Assert\Optional(new Assert\Email()),
281280
],
282281
]));

reference/constraints/Count.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ you might add the following:
4242
* maxMessage = "You cannot specify more than {{ limit }} emails"
4343
* )
4444
*/
45-
protected $emails = [];
45+
protected $emails = [];
4646
}
4747
4848
.. code-block:: yaml
@@ -90,8 +90,8 @@ you might add the following:
9090
public static function loadValidatorMetadata(ClassMetadata $metadata)
9191
{
9292
$metadata->addPropertyConstraint('emails', new Assert\Count([
93-
'min' => 1,
94-
'max' => 5,
93+
'min' => 1,
94+
'max' => 5,
9595
'minMessage' => 'You must specify at least one email',
9696
'maxMessage' => 'You cannot specify more than {{ limit }} emails',
9797
]));

reference/constraints/Country.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Basic Usage
2929
/**
3030
* @Assert\Country
3131
*/
32-
protected $country;
32+
protected $country;
3333
}
3434
3535
.. code-block:: yaml

reference/constraints/Date.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Basic Usage
3131
* @Assert\Date
3232
* @var string A "Y-m-d" formatted value
3333
*/
34-
protected $birthday;
34+
protected $birthday;
3535
}
3636
3737
.. code-block:: yaml

reference/constraints/DateTime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Basic Usage
3232
* @Assert\DateTime
3333
* @var string A "Y-m-d H:i:s" formatted value
3434
*/
35-
protected $createdAt;
35+
protected $createdAt;
3636
}
3737
3838
.. code-block:: yaml

0 commit comments

Comments
 (0)