You are here

public function UrlloginForm::validateForm in urllogin 2.x

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

Class

UrlloginForm
Implements an urllgoin admin form.

Namespace

Drupal\urllogin\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $entry = $form_state
    ->getValue('urllogin_codekey');

  // Test for digits.
  if (preg_match('@^[0-9]+$@', trim($entry)) != 1) {
    $form_state
      ->setErrorByName('urllogin_codekey', $this
      ->t('Please enter a positive integer for Validation number.'));
  }
  $entry = $form_state
    ->getValue('urllogin_codemin');

  // Test for digits.
  if (preg_match('@^[0-9]+$@', trim($entry)) != 1) {
    $form_state
      ->setErrorByName('urllogin_codemin', $this
      ->t('Please enter a positive integer for Minimum validation number.'));
  }
}