public function PathConfigForm::validateForm in JSON Web Token Authentication (JWT) 8
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
- modules/
jwt_path_auth/ src/ Form/ PathConfigForm.php, line 53
Class
- PathConfigForm
- Class ConfigForm.
Namespace
Drupal\jwt_path_auth\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$string = $form_state
->getValue('allowed_path_prefixes');
$list = explode("\n", $string);
$list = array_map('trim', $list);
$prefix_list = array_filter($list, 'strlen');
foreach ($prefix_list as $path) {
if ($path[0] !== '/') {
$form_state
->setErrorByName('allowed_path_prefixes', $this
->t('Paths must start with a slash.'));
return;
}
}
$form_state
->setTemporaryValue('prefix_list', $prefix_list);
}