Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit40deb21

Browse files
committed
minor#15016 [Validator] Add PHP Attributes to severity and translation examples (wkania)
This PR was merged into the 5.2 branch.Discussion----------[Validator] Add PHP Attributes to severity and translation examples<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/releases for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `5.x` for features of unreleased versions).-->Commits-------6f8ff25 [Validator] Add PHP Attributes to severity and translation examples
2 parents5d9a064 +6f8ff25 commit40deb21

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)

[8]ページ先頭

©2009-2025 Movatter.jp