Version 1
[yaffs-website] / web / core / modules / comment / src / Plugin / Validation / Constraint / CommentNameConstraint.php
1 <?php
2
3 namespace Drupal\comment\Plugin\Validation\Constraint;
4
5 use Drupal\Core\Entity\Plugin\Validation\Constraint\CompositeConstraintBase;
6
7 /**
8  * Supports validating comment author names.
9  *
10  * @Constraint(
11  *   id = "CommentName",
12  *   label = @Translation("Comment author name", context = "Validation"),
13  *   type = "entity:comment"
14  * )
15  */
16 class CommentNameConstraint extends CompositeConstraintBase {
17
18   /**
19    * Message shown when an anonymous user comments using a registered name.
20    *
21    * @var string
22    */
23   public $messageNameTaken = 'The name you used (%name) belongs to a registered user.';
24
25   /**
26    * Message shown when an admin changes the comment-author to an invalid user.
27    *
28    * @var string
29    */
30   public $messageRequired = 'You have to specify a valid author.';
31
32   /**
33    * Message shown when the name doesn't match the author's name.
34    *
35    * @var string
36    */
37   public $messageMatch = 'The specified author name does not match the comment author.';
38
39   /**
40    * {@inheritdoc}
41    */
42   public function coversFields() {
43     return ['name', 'uid'];
44   }
45
46 }