You are here

public function BrokenLinkRedirectForm::validateForm in Broken Link 8

Same name and namespace in other branches
  1. 8.3 src/Form/BrokenLinkRedirectForm.php \Drupal\broken_link\Form\BrokenLinkRedirectForm::validateForm()
  2. 8.2 src/Form/BrokenLinkRedirectForm.php \Drupal\broken_link\Form\BrokenLinkRedirectForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/BrokenLinkRedirectForm.php, line 105

Class

BrokenLinkRedirectForm
Class BrokenLinkRedirectForm.

Namespace

Drupal\broken_link\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $redirect_path = $form_state
    ->getValue('redirect_path');
  $is_valid = $this->pathValidator
    ->isValid($redirect_path);
  if (!$is_valid) {
    $form_state
      ->setError($form['redirect_path'], 'Please enter valid redirect path.');
  }
  elseif (UrlHelper::isExternal($redirect_path)) {
    $form_state
      ->setError($form['redirect_path'], 'External redirect path is not allowed.');
  }
}