diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index 3a59e01..ba47925 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -101,6 +101,8 @@
   /**
    * Context in which this entity will be used (e.g. 'display', 'form').
    *
+   * Must contain lower case letters, numbers and underscores only.
+   *
    * @var string
    */
   protected $displayContext;
@@ -123,23 +125,18 @@
    * {@inheritdoc}
    */
   public function __construct(array $values, $entity_type) {
-    if (!isset($values['targetEntityType']) || !isset($values['bundle'])) {
-      throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.');
-    }
-
-    if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
-      throw new \InvalidArgumentException('EntityDisplay entities can only handle fieldable entity types.');
-    }
+    assert('isset($values[\'targetEntityType\']) && isset($values[\'bundle\'])', 'Missing required properties for an EntityDisplay entity.');
+    assert('is_string($values[\'targetEntityType\'])');
+    assert('is_string($values[\'bundle\'])');
+    assert('$this->entityManager()->getDefinition($values[\'targetEntityType\'])->isSubclassOf(\'\Drupal\Core\Entity\FieldableEntityInterface\')', 'EntityDisplay entities can only handle fieldable entity types.');
+    // A plugin manager and a context type need to be set by extending classes.
+    assert('isset($this->pluginManager)', 'Missing plugin manager. The plugin manager must be set before parent::__construct() is called.');
+    assert('isset($this->displayContext)', 'Missing display context type. The display context type must be set before parent::__construct() is called.');
+    assert('$this->pluginManager instanceof \Drupal\Component\Plugin\PluginManagerInterface');
+    assert('is_string($this->displayContext) && !empty($this->displayContext) && preg_match(\'/^[a-z0-9_]+$/\', $this->displayContext)');
 
     $this->renderer = \Drupal::service('renderer');
 
-    // A plugin manager and a context type needs to be set by extending classes.
-    if (!isset($this->pluginManager)) {
-      throw new \RuntimeException('Missing plugin manager.');
-    }
-    if (!isset($this->displayContext)) {
-      throw new \RuntimeException('Missing display context type.');
-    }
 
     parent::__construct($values, $entity_type);
 
