@@ -139,8 +139,8 @@ following:
139
139
140
140
public static function loadValidatorMetadata(ClassMetadata $metadata): void
141
141
{
142
- $metadata->addPropertyConstraint('profileData', new Assert\Collection([
143
- ' fields' => [
142
+ $metadata->addPropertyConstraint('profileData', new Assert\Collection(
143
+ fields: [
144
144
'personal_email' => new Assert\Email(),
145
145
'short_bio' => [
146
146
new Assert\NotBlank(),
@@ -150,8 +150,8 @@ following:
150
150
]),
151
151
],
152
152
],
153
- ' allowMissingFields' => true,
154
- ] ));
153
+ allowMissingFields: true,
154
+ ));
155
155
}
156
156
}
157
157
@@ -267,15 +267,15 @@ you can do the following:
267
267
268
268
public static function loadValidatorMetadata(ClassMetadata $metadata): void
269
269
{
270
- $metadata->addPropertyConstraint('profileData', new Assert\Collection([
271
- ' fields' => [
270
+ $metadata->addPropertyConstraint('profileData', new Assert\Collection(
271
+ fields: [
272
272
'personal_email' => new Assert\Required([
273
273
new Assert\NotBlank(),
274
274
new Assert\Email(),
275
275
]),
276
276
'alternate_email' => new Assert\Optional(new Assert\Email()),
277
277
],
278
- ] ));
278
+ ));
279
279
}
280
280
}
281
281
@@ -291,28 +291,28 @@ groups. Take the following example::
291
291
292
292
use Symfony\Component\Validator\Constraints as Assert;
293
293
294
- $constraint = new Assert\Collection([
295
- ' fields' => [
294
+ $constraint = new Assert\Collection(
295
+ fields: [
296
296
'name' => new Assert\NotBlank(['groups' => 'basic']),
297
297
'email' => new Assert\NotBlank(['groups' => 'contact']),
298
298
],
299
- ] );
299
+ );
300
300
301
301
This will result in the following configuration::
302
302
303
- $constraint = new Assert\Collection([
304
- ' fields' => [
305
- 'name' => new Assert\Required([
306
- ' constraints' => new Assert\NotBlank([' groups' => 'basic']),
307
- ' groups' => ['basic', 'strict'],
308
- ] ),
309
- 'email' => new Assert\Required([
310
- " constraints" => new Assert\NotBlank([' groups' => 'contact']),
311
- ' groups' => ['basic', 'strict'],
312
- ] ),
303
+ $constraint = new Assert\Collection(
304
+ fields: [
305
+ 'name' => new Assert\Required(
306
+ constraints: new Assert\NotBlank(groups: [ 'basic']),
307
+ groups: ['basic', 'strict'],
308
+ ),
309
+ 'email' => new Assert\Required(
310
+ constraints: new Assert\NotBlank(groups: [ 'contact']),
311
+ groups: ['basic', 'strict'],
312
+ ),
313
313
],
314
- ' groups' => ['basic', 'strict'],
315
- ] );
314
+ groups: ['basic', 'strict'],
315
+ );
316
316
317
317
The default ``allowMissingFields `` option requires the fields in all groups.
318
318
So when validating in ``contact `` group, ``$name `` can be empty but the key is
@@ -360,7 +360,7 @@ Parameter Description
360
360
``fields ``
361
361
~~~~~~~~~~
362
362
363
- **type **: ``array `` [ :ref: ` default option < validation-default-option >`]
363
+ **type **: ``array ``
364
364
365
365
This option is required and is an associative array defining all of the
366
366
keys in the collection and, for each key, exactly which validator(s) should
0 commit comments