You are here

function jsonlog_form_system_logging_settings_validate in JSONlog 8

Same name and namespace in other branches
  1. 8.2 jsonlog.module \jsonlog_form_system_logging_settings_validate()
  2. 7.2 jsonlog.module \jsonlog_form_system_logging_settings_validate()
  3. 7 jsonlog.module \jsonlog_form_system_logging_settings_validate()
  4. 3.x jsonlog.module \jsonlog_form_system_logging_settings_validate()

Parameters

array $form:

FormStateInterface $form_state:

1 string reference to 'jsonlog_form_system_logging_settings_validate'
_jsonlog_form_system_logging_settings_alter in ./jsonlog.inc
Adds this module's setting fields to the system logging settings form.

File

./jsonlog.module, line 48
Contains jsonlog.module.

Code

function jsonlog_form_system_logging_settings_validate($form, FormStateInterface $form_state) {
  $values =& $form_state
    ->getValues();

  // Non-empty truncate must be non-negative integer.
  if ($values['jsonlog_truncate'] !== '' && ($value = trim($values['jsonlog_truncate'])) !== '') {
    if (!preg_match('/^\\d+$/', $value)) {
      $form_state
        ->setErrorByName('jsonlog_truncate', t('\'@field\' is not a non-negative integer.', [
        '@field' => t('Truncate events to'),
      ]));
    }
  }
}