You are here

public function VarnishPurgerFormBase::validateForm in Varnish purger 8.2

Same name and namespace in other branches
  1. 8 src/Form/VarnishPurgerFormBase.php \Drupal\varnish_purger\Form\VarnishPurgerFormBase::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/VarnishPurgerFormBase.php, line 442

Class

VarnishPurgerFormBase
Abstract form base for Varnish based configurable purgers.

Namespace

Drupal\varnish_purger\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {

  // Validate that our timeouts stay between the boundaries purge demands.
  $timeout = $form_state
    ->getValue('connect_timeout') + $form_state
    ->getValue('timeout');
  if ($timeout > 10) {
    $form_state
      ->setErrorByName('connect_timeout');
    $form_state
      ->setErrorByName('timeout', $this
      ->t('The sum of both timeouts cannot be higher than 10.00 as this would affect performance too negatively.'));
  }
  elseif ($timeout < 0.4) {
    $form_state
      ->setErrorByName('connect_timeout');
    $form_state
      ->setErrorByName('timeout', $this
      ->t('The sum of both timeouts cannot be lower as 0.4 as this can lead to too many failures under real usage conditions.'));
  }
}