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:
50
50
protected $bankAccountNumber;
51
51
}
52
52
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
+
53
72
.. code-block :: yaml
54
73
55
74
# 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:
40
40
public $name;
41
41
}
42
42
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
+
43
56
.. code-block :: yaml
44
57
45
58
# config/validator/validation.yaml
You can’t perform that action at this time.
0 commit comments