You are here

public function ValidatableConfigFormBase::validateForm in CDN 8.3

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

cdn_ui/src/Form/ValidatableConfigFormBase.php, line 48

Class

ValidatableConfigFormBase
@todo Lift the config validation logic out of this module into core.

Namespace

Drupal\cdn_ui\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $config = static::mapFormValuesToConfig($form_state, $this
    ->config(static::getMainConfigName()));
  $typed_config = $this->typedConfigManager
    ->createFromNameAndData(static::getMainConfigName(), $config
    ->getRawData());
  $violations = $typed_config
    ->validate();
  foreach ($violations as $violation) {
    $form_state
      ->setErrorByName(static::mapViolationPropertyPathsToFormNames($violation
      ->getPropertyPath()), $violation
      ->getMessage());
  }
}