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

reference/constraints/GreaterThanOrEqual.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The following constraints ensure that:
6161
protected $siblings;
6262
6363
#[Assert\GreaterThanOrEqual(
64-
value: 18
64+
value: 18,
6565
)]
6666
protected $age;
6767
}
@@ -152,7 +152,7 @@ that a date must at least be the current day:
152152
153153
class Order
154154
{
155-
#[Assert\GreaterThanOrEqual("today")]
155+
#[Assert\GreaterThanOrEqual('today')]
156156
protected $deliveryDate;
157157
}
158158
@@ -224,7 +224,7 @@ dates. If you want to fix the timezone, append it to the date string:
224224
225225
class Order
226226
{
227-
#[Assert\GreaterThanOrEqual("today UTC")]
227+
#[Assert\GreaterThanOrEqual('today UTC')]
228228
protected $deliveryDate;
229229
}
230230
@@ -297,7 +297,7 @@ current time:
297297
298298
class Order
299299
{
300-
#[Assert\GreaterThanOrEqual("+5 hours")]
300+
#[Assert\GreaterThanOrEqual('+5 hours')]
301301
protected $deliveryDate;
302302
}
303303

reference/constraints/Hostname.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ will contain a host name.
5151
5252
class ServerSettings
5353
{
54-
#[Assert\Hostname(message: "The server name must be a valid hostname.")]
54+
#[Assert\Hostname(message: 'The server name must be a valid hostname.')]
5555
protected $name;
5656
}
5757

reference/constraints/Iban.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ will contain an International Bank Account Number.
5050
class Transaction
5151
{
5252
#[Assert\Iban(
53-
message: "This is not a valid International Bank Account Number (IBAN)."
53+
message: 'This is not a valid International Bank Account Number (IBAN).',
5454
)]
5555
protected $bankAccountNumber;
5656
}

reference/constraints/IdenticalTo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The following constraints ensure that:
6767
protected $firstName;
6868
6969
#[Assert\IdenticalTo(
70-
value: 20
70+
value: 20,
7171
)]
7272
protected $age;
7373
}

reference/constraints/Image.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ that it is between a certain size, add the following:
113113
minWidth: 200,
114114
maxWidth: 400,
115115
minHeight: 200,
116-
maxHeight: 400
116+
maxHeight: 400,
117117
)]
118118
protected $headshot;
119119
}
@@ -209,7 +209,7 @@ following code:
209209
{
210210
#[Assert\Image(
211211
allowLandscape: false,
212-
allowPortrait: false
212+
allowPortrait: false,
213213
)]
214214
protected $headshot;
215215
}

reference/constraints/IsTrue.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Then you can validate this method with ``IsTrue`` as follows:
7171
{
7272
protected $token;
7373
74-
#[Assert\IsTrue(message: "The token is invalid.")]
74+
#[Assert\IsTrue(message: 'The token is invalid.')]
7575
public function isTokenValid()
7676
{
7777
return $this->token == $this->generateToken();

reference/constraints/Isbn.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ on an object that will contain an ISBN.
5353
class Book
5454
{
5555
#[Assert\Isbn(
56-
type: "isbn10",
57-
message : "This value is not valid."
56+
type: Assert\Isbn::ISBN_10,
57+
message : 'This value is not valid.',
5858
)]
5959
protected $isbn;
6060
}

reference/constraints/Length.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ and "50", you might add the following:
6060
#[Assert\Length(
6161
min: 2,
6262
max: 50,
63-
minMessage: "Your first name must be at least {{ limit }} characters long",
64-
maxMessage: "Your first name cannot be longer than {{ limit }} characters"
63+
minMessage: 'Your first name must be at least {{ limit }} characters long',
64+
maxMessage: 'Your first name cannot be longer than {{ limit }} characters',
6565
)]
6666
protected $firstName;
6767
}

reference/constraints/LessThan.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\LessThan(
65-
value: 80
65+
value: 80,
6666
)]
6767
protected $age;
6868
}
@@ -153,7 +153,7 @@ that a date must be in the past like this:
153153
154154
class Person
155155
{
156-
#[Assert\LessThan("today")]
156+
#[Assert\LessThan('today')]
157157
protected $dateOfBirth;
158158
}
159159
@@ -225,7 +225,7 @@ dates. If you want to fix the timezone, append it to the date string:
225225
226226
class Person
227227
{
228-
#[Assert\LessThan("today UTC")]
228+
#[Assert\LessThan('today UTC')]
229229
protected $dateOfBirth;
230230
}
231231
@@ -297,7 +297,7 @@ can check that a person must be at least 18 years old like this:
297297
298298
class Person
299299
{
300-
#[Assert\LessThan("-18 years")]
300+
#[Assert\LessThan('-18 years')]
301301
protected $dateOfBirth;
302302
}
303303

reference/constraints/LessThanOrEqual.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ The following constraints ensure that:
6060
#[Assert\LessThanOrEqual(5)]
6161
protected $siblings;
6262
63-
#[Assert\IsTrue(
64-
value: 80
63+
#[Assert\LessThanOrEqual(
64+
value: 80,
6565
)]
6666
protected $age;
6767
}
@@ -152,7 +152,7 @@ that a date must be today or in the past like this:
152152
153153
class Person
154154
{
155-
#[Assert\LessThanOrEqual("today")]
155+
#[Assert\LessThanOrEqual('today')]
156156
protected $dateOfBirth;
157157
}
158158
@@ -224,7 +224,7 @@ dates. If you want to fix the timezone, append it to the date string:
224224
225225
class Person
226226
{
227-
#[Assert\LessThanOrEqual("today UTC")]
227+
#[Assert\LessThanOrEqual('today UTC')]
228228
protected $dateOfBirth;
229229
}
230230
@@ -296,7 +296,7 @@ can check that a person must be at least 18 years old like this:
296296
297297
class Person
298298
{
299-
#[Assert\LessThanOrEqual("-18 years")]
299+
#[Assert\LessThanOrEqual('-18 years')]
300300
protected $dateOfBirth;
301301
}
302302

reference/constraints/Locale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Basic Usage
5353
class User
5454
{
5555
#[Assert\Locale(
56-
canonicalize: true
56+
canonicalize: true,
5757
)]
5858
protected $locale;
5959
}

reference/constraints/Luhn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ will contain a credit card number.
4646
4747
class Transaction
4848
{
49-
#[Assert\Luhn(message: "Please check your credit card number.")]
49+
#[Assert\Luhn(message: 'Please check your credit card number.')]
5050
protected $cardNumber;
5151
}
5252

reference/constraints/NotEqualTo.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ the following:
6262
6363
class Person
6464
{
65-
#[Assert\NotEqualTo("Mary")]
65+
#[Assert\NotEqualTo('Mary')]
6666
protected $firstName;
6767
6868
#[Assert\NotEqualTo(
69-
value: 15
69+
value: 15,
7070
)]
7171
protected $age;
7272
}

0 commit comments

Comments
 (0)