You are here

public function DataFieldRow::validateAliasName in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::validateAliasName()
  2. 9 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::validateAliasName()

Form element validation handler for \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm().

File

core/modules/rest/src/Plugin/views/row/DataFieldRow.php, line 113

Class

DataFieldRow
Plugin which displays fields as raw data.

Namespace

Drupal\rest\Plugin\views\row

Code

public function validateAliasName($element, FormStateInterface $form_state) {
  if (preg_match('@[^A-Za-z0-9_-]+@', $element['#value'])) {
    $form_state
      ->setError($element, $this
      ->t('The machine-readable name must contain only letters, numbers, dashes and underscores.'));
  }
}