@@ -144,10 +144,10 @@ following:
144144 'personal_email' => new Assert\Email(),
145145 'short_bio' => [
146146 new Assert\NotBlank(),
147- new Assert\Length([
148- ' max' => 100,
149- ' maxMessage' => 'Your short bio is too long!',
150- ] ),
147+ new Assert\Length(
148+ max: 100,
149+ maxMessage: 'Your short bio is too long!',
150+ ),
151151 ],
152152 ],
153153 allowMissingFields: true,
@@ -196,13 +196,13 @@ you can do the following:
196196 {
197197 #[Assert\Collection(
198198 fields: [
199- 'personal_email' => new Assert\Required([
199+ 'personal_email' => new Assert\Required(constraints: [
200200 new Assert\NotBlank,
201201 new Assert\Email,
202202 ]),
203- 'alternate_email' => new Assert\Optional(
203+ 'alternate_email' => new Assert\Optional(constraints: [
204204 new Assert\Email
205- ),
205+ ] ),
206206 ],
207207 )]
208208 protected array $profileData = ['personal_email' => 'email@example.com'];
@@ -218,11 +218,13 @@ you can do the following:
218218 fields :
219219 personal_email :
220220 - Required :
221- - NotBlank : ~
222- - Email : ~
221+ constraints :
222+ - NotBlank : ~
223+ - Email : ~
223224 alternate_email :
224225 - Optional :
225- - Email : ~
226+ constraints :
227+ - Email : ~
226228
227229 .. code-block :: xml
228230
@@ -238,13 +240,17 @@ you can do the following:
238240 <option name =" fields" >
239241 <value key =" personal_email" >
240242 <constraint name =" Required" >
241- <constraint name =" NotBlank" />
242- <constraint name =" Email" />
243+ <option name =" constraints" >
244+ <constraint name =" NotBlank" />
245+ <constraint name =" Email" />
246+ </option >
243247 </constraint >
244248 </value >
245249 <value key =" alternate_email" >
246250 <constraint name =" Optional" >
247- <constraint name =" Email" />
251+ <option name =" constraints" >
252+ <constraint name =" Email" />
253+ </option >
248254 </constraint >
249255 </value >
250256 </option >
@@ -269,11 +275,11 @@ you can do the following:
269275 {
270276 $metadata->addPropertyConstraint('profileData', new Assert\Collection(
271277 fields: [
272- 'personal_email' => new Assert\Required([
278+ 'personal_email' => new Assert\Required(constraints: [
273279 new Assert\NotBlank(),
274280 new Assert\Email(),
275281 ]),
276- 'alternate_email' => new Assert\Optional(new Assert\Email()),
282+ 'alternate_email' => new Assert\Optional(constraints: [ new Assert\Email()] ),
277283 ],
278284 ));
279285 }
@@ -293,8 +299,8 @@ groups. Take the following example::
293299
294300 $constraint = new Assert\Collection(
295301 fields: [
296- 'name' => new Assert\NotBlank([' groups' => 'basic']),
297- 'email' => new Assert\NotBlank([' groups' => 'contact']),
302+ 'name' => new Assert\NotBlank(groups: [ 'basic']),
303+ 'email' => new Assert\NotBlank(groups: [ 'contact']),
298304 ],
299305 );
300306
0 commit comments