File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,25 @@ Use the ``payload`` option to configure the error level for each constraint:
5050 protected $bankAccountNumber;
5151 }
5252
53+ .. code-block :: php-attributes
54+
55+ // src/Entity/User.php
56+ namespace App\Entity;
57+
58+ use Symfony\Component\Validator\Constraints as Assert;
59+
60+ class User
61+ {
62+ #[Assert\NotBlank(payload: ['severity' => 'error'])]
63+ protected $username;
64+
65+ #[Assert\NotBlank(payload: ['severity' => 'error'])]
66+ protected $password;
67+
68+ #[Assert\Iban(payload: ['severity' => 'warning'])]
69+ protected $bankAccountNumber;
70+ }
71+
5372 .. code-block :: yaml
5473
5574 # config/validator/validation.yaml
Original file line number Diff line number Diff line change @@ -40,6 +40,19 @@ property is not empty, add the following:
4040 public $name;
4141 }
4242
43+ .. code-block :: php-attributes
44+
45+ // src/Entity/Author.php
46+ namespace App\Entity;
47+
48+ use Symfony\Component\Validator\Constraints as Assert;
49+
50+ class Author
51+ {
52+ #[Assert\NotBlank(message: 'author.name.not_blank')]
53+ public $name;
54+ }
55+
4356 .. code-block :: yaml
4457
4558 # config/validator/validation.yaml
You can’t perform that action at this time.
0 commit comments