You are here

UniqueFieldConstraint.php in Zircon Profile 8.0

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php
View source
<?php

/**
 * @file
 * Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint.
 */
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;

/**
 * Checks if an entity field has a unique value.
 *
 * @Constraint(
 *   id = "UniqueField",
 *   label = @Translation("Unique field constraint", context = "Validation"),
 * )
 */
class UniqueFieldConstraint extends Constraint {
  public $message = 'A @entity_type with @field_name %value already exists.';

  /**
   * {@inheritdoc}
   */
  public function validatedBy() {
    return '\\Drupal\\Core\\Validation\\Plugin\\Validation\\Constraint\\UniqueFieldValueValidator';
  }

}

Classes

Namesort descending Description
UniqueFieldConstraint Checks if an entity field has a unique value.