You are here

protected function RestUIForm::validateFormValuesForResourceGranularity in REST UI 8

Form validation handler when the selected granularity is 'resource'.

Parameters

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

See also

\Drupal\restui\Form\RestUIForm::validateForm()

1 call to RestUIForm::validateFormValuesForResourceGranularity()
RestUIForm::validateForm in src/Form/RestUIForm.php

File

src/Form/RestUIForm.php, line 401

Class

RestUIForm
Provides a REST resource configuration form.

Namespace

Drupal\restui\Form

Code

protected function validateFormValuesForResourceGranularity(FormStateInterface $form_state) {
  $settings = $form_state
    ->getValue([
    'wrapper',
    'settings',
  ]);
  if (empty($settings) || empty(array_filter($settings['methods']))) {
    $form_state
      ->setErrorByName('methods', $this
      ->t('At least one HTTP method must be selected.'));
  }
  if (empty($settings) || empty(array_filter($settings['formats']))) {
    $form_state
      ->setErrorByName('formats', $this
      ->t('At least one request format must be selected.'));
  }
  if (empty($settings) || empty(array_filter($settings['authentication']))) {
    $form_state
      ->setErrorByName('authentication', $this
      ->t('At least one authentication provider must be selected'));
  }
}