You are here

function statsd_admin_settings_validate in StatsD 7.2

Same name and namespace in other branches
  1. 6 statsd.admin.inc \statsd_admin_settings_validate()
  2. 7 statsd.admin.inc \statsd_admin_settings_validate()

Validation handler for the administrative settings.

File

./statsd.admin.inc, line 90

Code

function statsd_admin_settings_validate($form, &$form_state) {
  $form_state['values']['statsd_host'] = trim($form_state['values']['statsd_host']);
  $form_state['values']['statsd_port'] = trim($form_state['values']['statsd_port']);
  $form_state['values']['statsd_sample_rate'] = trim($form_state['values']['statsd_sample_rate']);
  $form_state['values']['statsd_prefix'] = trim(rtrim($form_state['values']['statsd_prefix'], '.'));
  $form_state['values']['statsd_suffix'] = trim(ltrim($form_state['values']['statsd_suffix'], '.'));
  $sample_rate = $form_state['values']['statsd_sample_rate'];
  if (!is_numeric($sample_rate) || $sample_rate <= 0 || $sample_rate > 1) {
    form_set_error('statsd_sample_rate', t('The sample rate must be a value between 0 and 1'));
  }
}