8000 minor #17219 add missing attributes code block (xabbuh) · symfony/symfony-docs@ca7e57e · GitHub
[go: up one dir, main page]

Skip to content

Commit ca7e57e

Browse files
committed
minor #17219 add missing attributes code block (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- add missing attributes code block see #17196 (comment) Commits ------- 5dbab03 add missing attributes code block
2 parents 83912c6 + 5dbab03 commit ca7e57e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

reference/constraints/Collection.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,29 @@ you can do the following:
239239
protected $profileData = ['personal_email' => 'email@example.com'];
240240
}
241241
242+
.. code-block:: php-attributes
243+
244+
// src/Entity/Author.php
245+
namespace App\Entity;
246+
247+
use Symfony\Component\Validator\Constraints as Assert;
248+
249+
class Author
250+
{
251+
#[Assert\Collection(
252+
fields: [
253+
'personal_email' => new Assert\Required([
254+
new Assert\NotBlank,
255+
new Assert\Email,
256+
]),
257+
'alternate_email' => new Assert\Optional(
258+
new Assert\Email
259+
),
260+
],
261+
)]
262+
protected $profileData = ['personal_email' => 'email@example.com'];
263+
}
264+
242265
.. code-block:: yaml
243266
244267
# config/validator/validation.yaml

0 commit comments

Comments
 (0)
0