Skip to content

Commit cd5d590

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Validator] Add PHP Attributes to severity and translation examples
2 parents f05ec91 + 40deb21 commit cd5d590

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

validation/severity.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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

validation/translations.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)