public function HttpPurgerFormBase::validateForm in Generic HTTP Purger 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
- src/
Form/ HttpPurgerFormBase.php, line 518
Class
- HttpPurgerFormBase
- Abstract form base for HTTP based configurable purgers.
Namespace
Drupal\purge_purger_http\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Validate that our timeouts stay between the boundaries purge demands.
$timeout = (double) ($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.'));
}
}