You are here

function acquia_lift_admin_form_validate in Acquia Lift Connector 7

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

Validation callback for the Acquia Lift admin form.

File

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

Code

function acquia_lift_admin_form_validate($form, &$form_state) {
  if (!AcquiaLiftAPI::codeIsValid($form_state['values']['acquia_lift_account_info']['owner_code'])) {
    form_set_error('acquia_lift_account_info][owner_code', 'You must enter a valid owner code');
  }
  if (!valid_url($form_state['values']['acquia_lift_account_info']['api_url'])) {
    form_set_error('acquia_lift_account_info][api_url', t('You must enter a valid URL'));
  }

  // Strip any scheme from the API URL.
  $form_state['values']['acquia_lift_account_info']['api_url'] = preg_replace('/(^[a-z]+:\\/\\/)/i', '', $form_state['values']['acquia_lift_account_info']['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.'));
  }
}