8000 add missing attributes code block · githubfromgui/symfony-docs@5dbab03 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5dbab03

Browse files
committed
add missing attributes code block
1 parent 83912c6 commit 5dbab03

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