3 namespace Drupal\comment\Plugin\Validation\Constraint;
5 use Drupal\Core\Entity\Plugin\Validation\Constraint\CompositeConstraintBase;
8 * Supports validating comment author names.
12 * label = @Translation("Comment author name", context = "Validation"),
13 * type = "entity:comment"
16 class CommentNameConstraint extends CompositeConstraintBase {
19 * Message shown when an anonymous user comments using a registered name.
23 public $messageNameTaken = 'The name you used (%name) belongs to a registered user.';
26 * Message shown when an admin changes the comment-author to an invalid user.
30 public $messageRequired = 'You have to specify a valid author.';
33 * Message shown when the name doesn't match the author's name.
37 public $messageMatch = 'The specified author name does not match the comment author.';
42 public function coversFields() {
43 return ['name', 'uid'];