You are here

public function LostCharacterCaptchaSettingsForm::validateForm in CAPTCHA Pack 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

text_captcha/modules/lost_character_captcha/src/Form/LostCharacterCaptchaSettingsForm.php, line 90

Class

LostCharacterCaptchaSettingsForm
Function for the settings form.

Namespace

Drupal\lost_character_captcha\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $lost_quantity = (int) $form_state
    ->getValue('lost_character_captcha_quantity');
  $hinting = (int) $form_state
    ->getValue('lost_character_captcha_enable_hint');
  $min_length = 3 + 2 * $lost_quantity + (1 - $hinting);

  // Check the number of words in the pool.
  _text_captcha_word_pool_validate('lost_character_captcha_word_pool', $form_state, 3, $min_length, 'The following words are too short (at least @minimum_length characters needed for the current settings of characters to lose and hinting): <div>@words</div>');
  parent::validateForm($form, $form_state);
}