You are here

public function ProtectedPagesSettingForm::protectedPagesValidateIntegerPositive in Protected Pages 8

Form element validation handler to validate session expire time value..

File

src/Form/ProtectedPagesSettingForm.php, line 95

Class

ProtectedPagesSettingForm
Provides protected pages settings configuration form.

Namespace

Drupal\protected_pages\Form

Code

public function protectedPagesValidateIntegerPositive($element, FormStateInterface $form_state) {
  $value = $element['#value'];
  if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value < 0)) {
    $form_state
      ->setError($element, $this
      ->t('%name must be a positive integer.', [
      '%name' => $element['#title'],
    ]));
  }
}