You are here

function acquia_lift_admin_form_validate in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7.3 acquia_lift.admin.inc \acquia_lift_admin_form_validate()
  2. 7 acquia_lift.admin.inc \acquia_lift_admin_form_validate()

Validation callback for the Acquia Lift admin form.

File

./acquia_lift.admin.inc, line 243
acquia_lift.admin.inc Provides functions needed for the admin UI.

Code

function acquia_lift_admin_form_validate($form, &$form_state) {
  if (!valid_url($form_state['values']['acquia_lift_profiles_js_path'])) {
    form_set_error('acquia_lift_profiles_js_path', t('You must enter a valid JavaScript path'));
  }
  $form_state['values']['acquia_lift_profiles_js_path'] = preg_replace('/(^[a-z]+:\\/\\/)/i', '', $form_state['values']['acquia_lift_profiles_js_path']);

  // Validate the profiles api url.
  if (!valid_url($form_state['values']['acquia_lift_profiles_api_url'])) {
    form_set_error('acquia_lift_profiles_api_url', t('You must enter a valid API URL'));
  }

  // Strip any scheme from the API URL.
  $form_state['values']['acquia_lift_profiles_api_url'] = preg_replace('/(^[a-z]+:\\/\\/)/i', '', $form_state['values']['acquia_lift_profiles_api_url']);
  if ($form_state['values']['acquia_lift_confidence_measure'] <= 0 || $form_state['values']['acquia_lift_confidence_measure'] >= 100) {
    form_set_error('acquia_lift_confidence_measure', t('Confidence measure must be a value between 0 and 100.'));
  }
}