You are here

function akamai_settings_validate in Akamai 7.2

Validate the akamai_settings form.

File

./akamai.admin.inc, line 111
Akamai is a registered trademark of Akamai Technologies, Inc. Administrative pages for the Akamai module.

Code

function akamai_settings_validate($form, &$form_state) {

  // verify restapi and basepath are valid absolute URLs
  foreach (array(
    'akamai_basepath' => 'Base Path',
    'akamai_restapi' => 'REST API URL',
  ) as $field => $field_title) {
    if (!valid_url($form_state['values'][$field], TRUE)) {
      form_set_error($field, t("The %field_title value must be a valid, absolute URL", array(
        '%field_title' => $field_title,
      )));
    }
  }

  // If the password field is not set, remove it from the values array.
  // This prevents the value from being overwritten with an empty string.
  if (!$form_state['values']['akamai_password']) {
    unset($form_state['values']['akamai_password']);
  }

  // check if timeout value is an integer
  $filtered_akamai_timeout = filter_var($form_state['values']['akamai_timeout'], FILTER_VALIDATE_INT, array(
    'options' => array(
      'min_range' => 1,
    ),
  ));
  if (!$filtered_akamai_timeout) {
    form_set_error('akamai_timeout', 'The Timeout Length must be an integer greater than 0.');
  }
}