You are here

class EntityFieldUniqueValues in Helper 8

Checks if an entity field has duplicate values.

Plugin annotation


@Constraint(
  id = "HelperEntityFieldUniqueValues",
  label = @Translation("Unique field values", context = "Validation"),
  type = {"entity"},
)

Hierarchy

Expanded class hierarchy of EntityFieldUniqueValues

File

src/Plugin/Validation/Constraint/EntityFieldUniqueValues.php, line 14

Namespace

Drupal\helper\Plugin\Validation\Constraint
View source
class EntityFieldUniqueValues extends FieldListUniqueValues {

  /**
   * The field name to validate.
   *
   * @var string
   */
  public $field_name;

  /**
   * {@inheritdoc}
   */
  public function getDefaultOption() {
    return 'field_name';
  }

  /**
   * {@inheritdoc}
   */
  public function getRequiredOptions() {
    return [
      'field_name',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityFieldUniqueValues::$field_name public property The field name to validate.
EntityFieldUniqueValues::getDefaultOption public function Returns the name of the default option.
EntityFieldUniqueValues::getRequiredOptions public function Returns the name of the required options.
FieldListUniqueValues::$message public property Message if field contains duplicate values.
FieldListUniqueValues::$messageWithValues public property Message with values if field contains duplicate values.
FieldListUniqueValues::$property public property The field property to use when searching for values.
FieldListUniqueValues::$show_values public property If the message should show the field values that are duplicates.