Skip to content

Commit 8c8e1a9

Browse files
committed
After review fix
1 parent cc666fe commit 8c8e1a9

29 files changed

+78
-80
lines changed

reference/constraints/CardScheme.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ on an object that will contain a credit card number.
5151
class Transaction
5252
{
5353
#[Assert\CardScheme(
54-
schemes: ["VISA"],
55-
message: "Your credit card number is invalid."
56-
)]
54+
schemes: [Assert\CardScheme::VISA],
55+
message: 'Your credit card number is invalid.',
56+
)]
5757
protected $cardNumber;
5858
}
5959

reference/constraints/Choice.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,10 @@ If your valid choice list is simple, you can pass them in directly via the
6969
{
7070
const GENRES = ['fiction', 'non-fiction'];
7171
72-
#[Assert\Choice(["New York", "Berlin", "Tokyo"])]
72+
#[Assert\Choice(['New York', 'Berlin', 'Tokyo'])]
7373
protected $city;
7474
75-
/**
76-
* You can also directly provide an array constant to the "choices" option in the annotation
77-
*/
78-
#[Assert\Choice(choices: Conference::GENRES, message: "Choose a valid genre.")]
75+
#[Assert\Choice(choices: Author::GENRES, message: 'Choose a valid genre.')]
7976
protected $genre;
8077
}
8178
@@ -190,7 +187,7 @@ constraint.
190187
191188
class Author
192189
{
193-
#[Assert\Choice(callback: "getGenres")]
190+
#[Assert\Choice(callback: 'getGenres')]
194191
protected $genre;
195192
}
196193
@@ -264,11 +261,12 @@ you can pass the class name and the method as an array.
264261
// src/Entity/Author.php
265262
namespace App\Entity;
266263
264+
use App\Entity\Genre
267265
use Symfony\Component\Validator\Constraints as Assert;
268266
269267
class Author
270268
{
271-
#[Assert\Choice(callback: ["App\Entity\Genre", "getGenres"])]
269+
#[Assert\Choice(callback: [Genre::class, 'getGenres'])]
272270
protected $genre;
273271
}
274272

reference/constraints/Count.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ you might add the following:
5959
#[Assert\Count(
6060
min: 1,
6161
max: 5,
62-
minMessage: "You must specify at least one email",
63-
maxMessage: "You cannot specify more than {{ limit }} emails"
62+
minMessage: 'You must specify at least one email',
63+
maxMessage: 'You cannot specify more than {{ limit }} emails',
6464
)]
6565
protected $emails = [];
6666
}

reference/constraints/DivisibleBy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The following constraints ensure that:
6666
protected $weight;
6767
6868
#[Assert\DivisibleBy(
69-
value: 5
69+
value: 5,
7070
)]
7171
protected $quantity;
7272
}

reference/constraints/Email.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Basic Usage
4747
class Author
4848
{
4949
#[Assert\Email(
50-
message: "The email '{{ value }}' is not a valid email."
50+
message: 'The email {{ value }} is not a valid email.',
5151
)]
5252
protected $email;
5353
}

reference/constraints/EqualTo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ and that the ``age`` is ``20``, you could do the following:
6565
protected $firstName;
6666
6767
#[Assert\EqualTo(
68-
value: 20
68+
value: 20,
6969
)]
7070
protected $age;
7171
}

reference/constraints/Expression.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ One way to accomplish this is with the Expression constraint:
8787
8888
#[Assert\Expression(
8989
"this.getCategory() in ['php', 'symfony'] or !this.isTechnicalPost()",
90-
message: "If this is a tech post, the category should be either php or symfony!"
90+
message: 'If this is a tech post, the category should be either php or symfony!',
9191
)]
9292
class BlogPost
9393
{
@@ -192,7 +192,7 @@ more about the expression language syntax, see
192192
193193
#[Assert\Expression(
194194
"this.getCategory() in ['php', 'symfony'] or value == false",
195-
message: "If this is a tech post, the category should be either php or symfony!"
195+
message: 'If this is a tech post, the category should be either php or symfony!',
196196
)]
197197
private $isTechnicalPost;
198198
@@ -345,8 +345,8 @@ type (numeric, boolean, strings, null, etc.)
345345
class Analysis
346346
{
347347
#[Assert\Expression(
348-
"value + error_margin < threshold",
349-
values: ["error_margin" => 0.25, "threshold" => 1.5]
348+
'value + error_margin < threshold',
349+
values: ['error_margin' => 0.25, 'threshold' => 1.5],
350350
)]
351351
private $metric;
352352

reference/constraints/ExpressionLanguageSyntax.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ The following constraints ensure that:
6565
protected $promotion;
6666
6767
#[Assert\ExpressionLanguageSyntax(
68-
allowedVariables: ["user", "shipping_centers"]
68+
allowedVariables: ['user', 'shipping_centers'],
6969
)]
7070
protected $shippingOptions;
7171
}

reference/constraints/File.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ below a certain file size and a valid PDF, add the following:
103103
class Author
104104
{
105105
#[Assert\File(
106-
maxSize: "1024k",
107-
mimeTypes: ["application/pdf", "application/x-pdf"],
108-
mimeTypesMessage: "Please upload a valid PDF"
106+
maxSize: '1024k',
107+
mimeTypes: ['application/pdf', 'application/x-pdf'],
108+
mimeTypesMessage: 'Please upload a valid PDF',
109109
)]
110110
protected $bioFile;
111111
}

reference/constraints/GreaterThan.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The following constraints ensure that:
6262
protected $siblings;
6363
6464
#[Assert\GreaterThan(
65-
value: 18
65+
value: 18,
6666
)]
6767
protected $age;
6868
}
@@ -153,7 +153,7 @@ that a date must at least be the next day:
153153
154154
class Order
155155
{
156-
#[Assert\GreaterThan("today")]
156+
#[Assert\GreaterThan('today')]
157157
protected $deliveryDate;
158158
}
159159
@@ -225,7 +225,7 @@ dates. If you want to fix the timezone, append it to the date string:
225225
226226
class Order
227227
{
228-
#[Assert\GreaterThan("today UTC")]
228+
#[Assert\GreaterThan('today UTC')]
229229
protected $deliveryDate;
230230
}
231231
@@ -298,7 +298,7 @@ current time:
298298
299299
class Order
300300
{
301-
#[Assert\GreaterThan("+5 hours")]
301+
#[Assert\GreaterThan('+5 hours')]
302302
protected $deliveryDate;
303303
}
304304

0 commit comments

Comments
 (0)