class EntityBundleExistsConstraint
Checks if a bundle exists on a certain content entity type.
This differs from the `Bundle` constraint in that checks that the validated value is the *name of a bundle* of a particular entity type.
Attributes
#[Constraint(id: 'EntityBundleExists', label: new TranslatableMarkup('Entity bundle exists', [], [
'context' => 'Validation',
]), type: 'entity')]
  Hierarchy
- class \Drupal\Core\Validation\Plugin\Validation\Constraint\EntityBundleExistsConstraint extends \Symfony\Component\Validator\Constraint
 
Expanded class hierarchy of EntityBundleExistsConstraint
File
- 
              core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ EntityBundleExistsConstraint.php, line 17  
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintView source
class EntityBundleExistsConstraint extends SymfonyConstraint {
  
  /**
   * The error message if validation fails.
   *
   * @var string
   */
  public $message = "The '@bundle' bundle does not exist on the '@entity_type_id' entity type.";
  
  /**
   * The entity type ID which should have the given bundle.
   *
   * This can contain variable values (e.g., `%parent`) that will be replaced.
   *
   * @see \Drupal\Core\Config\Schema\TypeResolver::replaceVariable()
   *
   * @var string
   */
  public string $entityTypeId;
  
  /**
   * {@inheritdoc}
   *
   * @return ?string
   *   Name of the default option.
   *
   * @todo Add method return type declaration.
   * @see https://www.drupal.org/project/drupal/issues/3425150
   */
  public function getDefaultOption() {
    return 'entityTypeId';
  }
  
  /**
   * {@inheritdoc}
   *
   * @return array
   *   The names of the required options.
   *
   * @todo Add method return type declaration.
   * @see https://www.drupal.org/project/drupal/issues/3425150
   */
  public function getRequiredOptions() {
    return [
      'entityTypeId',
    ];
  }
}
Members
| Title Sort descending | Modifiers | Object type | Summary | 
|---|---|---|---|
| EntityBundleExistsConstraint::$entityTypeId | public | property | The entity type ID which should have the given bundle. | 
| EntityBundleExistsConstraint::$message | public | property | The error message if validation fails. | 
| EntityBundleExistsConstraint::getDefaultOption | public | function | @todo Add method return type declaration. | 
| EntityBundleExistsConstraint::getRequiredOptions | public | function | @todo Add method return type declaration. | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.