You are here

public function OAuthKeyForm::validateKeyFileName in Lightning API 8

Same name and namespace in other branches
  1. 8.4 src/Form/OAuthKeyForm.php \Drupal\lightning_api\Form\OAuthKeyForm::validateKeyFileName()
  2. 8.2 src/Form/OAuthKeyForm.php \Drupal\lightning_api\Form\OAuthKeyForm::validateKeyFileName()
  3. 8.3 src/Form/OAuthKeyForm.php \Drupal\lightning_api\Form\OAuthKeyForm::validateKeyFileName()

Ensures that a requested file name contains no illegal characters.

Parameters

array $element: The form element being validated.

FormStateInterface $form_state: The current form state.

File

src/Form/OAuthKeyForm.php, line 158

Class

OAuthKeyForm

Namespace

Drupal\lightning_api\Form

Code

public function validateKeyFileName(array &$element, FormStateInterface $form_state) {
  $value = $element['#value'];
  if (strpos($value, '/') !== FALSE) {
    $form_state
      ->setError($element, $this
      ->t('%value is not a valid name for a key file.', [
      '%value' => $value,
    ]));
  }
}