diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php
index fbb7442..a774819 100644
--- a/core/modules/comment/src/CommentForm.php
+++ b/core/modules/comment/src/CommentForm.php
@@ -250,15 +250,13 @@ public function validate(array $form, FormStateInterface $form_state) {
     $entity = $this->entity;
 
     if (!$entity->isNew()) {
-      // Verify the name in case it is being changed from being anonymous.
-      $accounts = $this->entityManager->getStorage('user')->loadByProperties(array('name' => $form_state->getValue('name')));
-      $account = reset($accounts);
-      $form_state->setValue('uid', $account ? $account->id() : 0);
-
       $date = $form_state->getValue('date');
       if ($date instanceOf DrupalDateTime && $date->hasErrors()) {
         $form_state->setErrorByName('date', $this->t('You have to specify a valid date.'));
       }
+      $accounts = $this->entityManager->getStorage('user')
+        ->loadByProperties(array('name' => $form_state->getValue('name')));
+      $account = reset($accounts);
       if ($form_state->getValue('name') && !$form_state->getValue('is_anonymous') && !$account) {
         $form_state->setErrorByName('name', $this->t('You have to specify a valid author.'));
       }
@@ -280,6 +278,7 @@ public function validate(array $form, FormStateInterface $form_state) {
    * Overrides EntityForm::buildEntity().
    */
   public function buildEntity(array $form, FormStateInterface $form_state) {
+    /** @var \Drupal\comment\CommentInterface $comment */
     $comment = parent::buildEntity($form, $form_state);
     if (!$form_state->isValueEmpty('date') && $form_state->getValue('date') instanceOf DrupalDateTime) {
       $comment->setCreatedTime($form_state->getValue('date')->getTimestamp());
@@ -287,6 +286,15 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
     else {
       $comment->setCreatedTime(REQUEST_TIME);
     }
+    if (!$comment->isNew()) {
+      // Verify the name in case it is being changed from being anonymous.
+      $accounts = $this->entityManager->getStorage('user')
+        ->loadByProperties(array('name' => $form_state->getValue('name')));
+      $account = reset($accounts);
+      $uid = $account ? $account->id() : 0;
+      $form_state->setValue('uid', $uid);
+      $comment->setOwnerId($uid);
+    }
     $comment->changed->value = REQUEST_TIME;
     return $comment;
   }
diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php
index 8b24aba..be4eeb1 100644
--- a/core/modules/comment/src/Entity/Comment.php
+++ b/core/modules/comment/src/Entity/Comment.php
@@ -256,7 +256,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
       ->setTranslatable(TRUE)
       ->setSetting('max_length', 60)
       ->setDefaultValue('')
-      ->addConstraint('CommentName', array());
+      ->addConstraint('CommentName', array())
+      ->addConstraint('CommentAuthor', array());
 
     $fields['mail'] = BaseFieldDefinition::create('email')
       ->setLabel(t('Email'))
@@ -540,7 +541,9 @@ public function getOwner() {
    * {@inheritdoc}
    */
   public function getOwnerId() {
-    return $this->get('uid')->target_id;
+    // Submitted form values are strings, but comment validation does strict
+    // checking. Consequently cast to an integer.
+    return (int) $this->get('uid')->target_id;
   }
 
   /**
diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentAuthorConstraint.php
similarity index 54%
copy from core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
copy to core/modules/comment/src/Plugin/Validation/Constraint/CommentAuthorConstraint.php
index 575a393..9efca58 100644
--- a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
+++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentAuthorConstraint.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Contains \Drupal\comment\Plugin\Validation\Constraint\CommentNameConstraint.
+ * Contains \Drupal\comment\Plugin\Validation\Constraint\CommentAuthorConstraint.
  */
 
 namespace Drupal\comment\Plugin\Validation\Constraint;
@@ -13,12 +13,12 @@
  * Supports validating comment author names.
  *
  * @Plugin(
- *   id = "CommentName",
- *   label = @Translation("Comment author name", context = "Validation")
+ *   id = "CommentAuthor",
+ *   label = @Translation("Comment author", context = "Validation")
  * )
  */
-class CommentNameConstraint extends Constraint {
+class CommentAuthorConstraint extends Constraint {
 
-  public $message = '%name belongs to a registered user.';
+  public $message = 'You have to specify a valid author.';
 
 }
diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentAuthorConstraintValidator.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentAuthorConstraintValidator.php
new file mode 100644
index 0000000..605e9d5
--- /dev/null
+++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentAuthorConstraintValidator.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\comment\Plugin\Validation\Constraint\CommentAuthorConstraintValidator.
+ */
+
+namespace Drupal\comment\Plugin\Validation\Constraint;
+
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\user\EntityOwnerInterface;
+use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\ConstraintValidator;
+
+/**
+ * Validates the CommentName constraint.
+ */
+class CommentAuthorConstraintValidator extends ConstraintValidator {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validate($items, Constraint $constraint) {
+    /** @var \Drupal\Core\Field\FieldItemList $items */
+    if (($entity = $items->getEntity()) &&
+      $entity instanceof EntityOwnerInterface &&
+      $entity->getOwnerId() === 0
+    ) {
+      // Anonymous account might be required - depending on field settings.
+      $anonymous_contact = $this->getAnonymousContactSetting($entity);
+      $author_name = $items->first()->value;
+      if (empty($author_name) && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT) {
+        $this->context->addViolation($constraint->message);
+      }
+    }
+  }
+
+  /**
+   * Gets the anonymous contact setting for the entity.
+   *
+   * @param \Drupal\Core\Entity\EntityInterface $entity
+   *   The entity.
+   *
+   * @return int
+   *   The anonymous contact setting.
+   */
+  protected function getAnonymousContactSetting(EntityInterface $entity) {
+    return $entity
+      ->getCommentedEntity()
+      ->get($entity->getFieldName())
+      ->getFieldDefinition()
+      ->getSettings()['anonymous'];
+  }
+
+}
diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
index 575a393..5bdf6ad 100644
--- a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
+++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
@@ -19,6 +19,6 @@
  */
 class CommentNameConstraint extends Constraint {
 
-  public $message = '%name belongs to a registered user.';
+  public $message = 'The name you used (%name) belongs to a registered user.';
 
 }
diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/src/Tests/CommentAnonymousTest.php
index 19fc6fa..8e1681c 100644
--- a/core/modules/comment/src/Tests/CommentAnonymousTest.php
+++ b/core/modules/comment/src/Tests/CommentAnonymousTest.php
@@ -67,7 +67,9 @@ function testAnonymous() {
       'comment_body[0][value]' => $this->randomMachineName(),
     );
     $this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit, t('Save'));
-    $this->assertText(t('The name you used belongs to a registered user.'));
+    $this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
+      '%name' => $this->adminUser->getUsername(),
+    ]));
 
     // Require contact info.
     $this->drupalLogin($this->adminUser);
diff --git a/core/modules/comment/src/Tests/CommentValidationTest.php b/core/modules/comment/src/Tests/CommentValidationTest.php
index cf627c4..fba6163 100644
--- a/core/modules/comment/src/Tests/CommentValidationTest.php
+++ b/core/modules/comment/src/Tests/CommentValidationTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\comment\Tests;
 
 use Drupal\comment\CommentInterface;
+use Drupal\node\Entity\Node;
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
 
 /**
@@ -36,6 +37,10 @@ protected function setUp() {
    * Tests the comment validation constraints.
    */
   public function testValidation() {
+    // Add a user.
+    $user = entity_create('user', array('name' => 'test'));
+    $user->save();
+
     // Add comment type.
     $this->entityManager->getStorage('comment_type')->create(array(
       'id' => 'comment',
@@ -60,12 +65,14 @@ public function testValidation() {
     ))->save();
 
     // Add comment field to page content.
-    $this->entityManager->getStorage('field_config')->create(array(
+    /** @var \Drupal\field\FieldConfigInterface $field */
+    $field = $this->entityManager->getStorage('field_config')->create(array(
       'field_name' => 'comment',
       'entity_type' => 'node',
       'bundle' => 'page',
       'label' => 'Comment settings',
-    ))->save();
+    ));
+    $field->save();
 
     $node = $this->entityManager->getStorage('node')->create(array(
       'type' => 'page',
@@ -78,6 +85,7 @@ public function testValidation() {
       'entity_type' => 'node',
       'field_name' => 'comment',
       'comment_body' => $this->randomMachineName(),
+      'uid' => $user->id(),
     ));
 
     $violations = $comment->validate();
@@ -93,13 +101,12 @@ public function testValidation() {
 
     // Validate a name collision between an anonymous comment author name and an
     // existing user account name.
-    $user = entity_create('user', array('name' => 'test'));
-    $user->save();
     $comment->set('name', 'test');
+    $comment->set('uid', 0);
     $violations = $comment->validate();
     $this->assertEqual(count($violations), 1, "Violation found on author name collision");
     $this->assertEqual($violations[0]->getPropertyPath(), "name");
-    $this->assertEqual($violations[0]->getMessage(), t('%name belongs to a registered user.', array('%name' => 'test')));
+    $this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', array('%name' => 'test')));
 
     // Make the name valid.
     $comment->set('name', 'valid unused name');
@@ -128,6 +135,28 @@ public function testValidation() {
     $comment->set('hostname', NULL);
     $comment->set('thread', $this->randomString(256));
     $this->assertLengthViolation($comment, 'thread', 255);
+
+    $comment->set('thread', NULL);
+
+    // Force anonymous users to enter contact details.
+    $field->settings['anonymous'] = COMMENT_ANONYMOUS_MUST_CONTACT;
+    $field->save();
+    // Reset the node entity.
+    \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
+    $node = Node::load($node->id());
+    // Create a new comment with the new field.
+    $comment = $this->entityManager->getStorage('comment')->create(array(
+      'entity_id' => $node->id(),
+      'entity_type' => 'node',
+      'field_name' => 'comment',
+      'comment_body' => $this->randomMachineName(),
+      'uid' => 0,
+      'name' => '',
+    ));
+    $violations = $comment->validate();
+    $this->assertEqual(count($violations), 1, 'Violation found when name is required, but empty and UID is anonymous.');
+    $this->assertEqual($violations[0]->getPropertyPath(), 'name');
+    $this->assertEqual($violations[0]->getMessage(), t('You have to specify a valid author.'));
   }
 
   /**
