Skip to content

Commit dda650a

Browse files
authored
Wording validation
1 parent 23d7dcf commit dda650a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/validation.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,10 @@ In this example, only `severity` and `anotherPayloadField` will be serialized.
455455

456456
## Validation on Collection Relations
457457

458+
Use the [Valid](https://symfony.com/doc/current/reference/constraints/Valid.html) constraint.
459+
458460
Note: this is related to the [collection relation denormalization](./serialization.md#collection-relation).
459-
You may have an issue when trying to validate a relation representing a collection (`toMany`). After fixing the denormalization by using a getter that returns `$collectionRelation->getValues()`, you should define your validation on the getter instead of the property.
461+
You may have an issue when trying to validate a relation representing a Doctrine's `ArrayCollection` (`toMany`). Fix the denormalization using the property getter. Return an `array` instead of an `ArrayCollection` with `$collectionRelation->getValues()`. Then, define your validation on the getter instead of the property.
460462

461463
For example:
462464

@@ -467,6 +469,13 @@ For example:
467469
```
468470

469471
```php
472+
<?php
473+
474+
namespace App\Entity;
475+
476+
use Doctrine\Common\Collections\ArrayCollection;
477+
use Symfony\Component\Validator\Constraints as Assert;
478+
470479
final class Brand
471480
{
472481
// ...

0 commit comments

Comments
 (0)