diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index 025cb5fc2f..efe5afc22b 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -802,3 +802,16 @@ function entity_test_query_entity_test_access_alter(AlterableInterface $query) {
     $query->condition('entity_test_query_access.name', 'published entity');
   }
 }
+
+/**
+ * Implements hook_entity_type_build().
+ */
+function entity_test_entity_type_build(array &$entity_types) {
+  if ($extra = \Drupal::state()->get('entity_test_build.constraints')) {
+    foreach ($extra as $entity_type => $constraints) {
+      foreach ($constraints as $constraint => $options) {
+        $entity_types[$entity_type]->addConstraint($constraint, $options);
+      }
+    }
+  }
+}
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/ValidateReferencesConstraint.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/ValidateReferencesConstraint.php
new file mode 100644
index 0000000000..d0ecf0562a
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/ValidateReferencesConstraint.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Drupal\entity_test\Plugin\Validation\Constraint;
+
+use Symfony\Component\Validator\Constraint;
+
+/**
+ * Supports validating referenced entities on a entity reference field.
+ *
+ * @Constraint(
+ *   id = "ValidateReferencesConstraint",
+ *   label = @Translation("Entity field reference constraint.")
+ * )
+ */
+class ValidateReferencesConstraint extends Constraint {
+
+  public $message = 'The referenced entity "%label" has failed the validation.';
+
+}
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/ValidateReferencesConstraintValidator.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/ValidateReferencesConstraintValidator.php
new file mode 100644
index 0000000000..1d6042b6d0
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/ValidateReferencesConstraintValidator.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\entity_test\Plugin\Validation\Constraint;
+
+use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\ConstraintValidator;
+
+/**
+ * Validates the ValidateReferencesConstraint constraint.
+ */
+class ValidateReferencesConstraintValidator extends ConstraintValidator {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validate($entity, Constraint $constraint) {
+    // The entities which could be created should run through the entity
+    // validation before being saved.
+    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
+    foreach ($entity->referencedEntities() as $referenced_entity) {
+      $violations = $referenced_entity->getTypedData()->validate();
+      if ($violations->count() != 0) {
+        // Add the reason for the validation failure to the current context.
+        $this->context->buildViolation($constraint->message)
+          ->setParameter('%label', $referenced_entity->label())
+          ->setInvalidValue($referenced_entity)
+          ->addViolation();
+      }
+    }
+  }
+
+}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/RecursiveContextualValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/RecursiveContextualValidatorTest.php
new file mode 100644
index 0000000000..b277f10478
--- /dev/null
+++ b/core/tests/Drupal/KernelTests/Core/Entity/RecursiveContextualValidatorTest.php
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\KernelTests\Core\Entity\RecursiveContextualValidatorTest.
+ */
+
+namespace Drupal\KernelTests\Core\Entity;
+
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\entity_test\Entity\EntityTestConstraintViolation;
+use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
+
+
+/**
+ * Tests recursive validation of entity references.
+ *
+ * @group Validation
+ */
+class RecursiveContextualValidatorTest extends EntityKernelTestBase {
+
+  use EntityReferenceTestTrait;
+
+  /**
+   * The typed data manager to use.
+   *
+   * @var \Drupal\Core\TypedData\TypedDataManager
+   */
+  protected $typedData;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['field', 'user'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Add the constraint which will trigger the validation of the referenced
+    // entities.
+    $this->container->get('entity_type.manager')->clearCachedDefinitions();
+    $extra_constraints = ['entity_test_constraint_violation' => ['ValidateReferencesConstraint' => []]];
+    $this->state->set('entity_test_build.constraints', $extra_constraints);
+  }
+
+  /**
+   * Tests the validation of new entities on an entity reference field.
+   */
+  public function testNewEntitiesValidation() {
+    // Add an entity reference field.
+    $this->createEntityReferenceField(
+      'entity_test_constraint_violation',
+      'entity_test_constraint_violation',
+      'field_test',
+      'Field test',
+      'entity_test_constraint_violation',
+      'default',
+      ['target_bundles' => ['entity_test_constraint_violation']],
+      FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED
+    );
+
+    // Create a new entity which will be referenced and should fail the
+    // validation.
+    $referenced_new_entity = EntityTestConstraintViolation::create([
+      'name' => 'B',
+      'user_id' => ['target_id' => 0],
+    ]);
+
+    $referencing_entity = EntityTestConstraintViolation::create([
+      'name' => 'A',
+      'user_id' => ['target_id' => 0],
+      'field_test' => [
+        ['entity' => $referenced_new_entity],
+      ]
+    ]);
+
+    $violations = $referencing_entity->validate();
+    $this->assertCount(2, $violations);
+    $this->assertEquals(t('The referenced entity "%label" has failed the validation.', [
+      '%label' => 'B',
+    ]), $violations[0]->getMessage());
+    $this->assertEquals(t('Widget constraint has failed.'), $violations[1]->getMessage());
+  }
+
+}
