You are here

function oauthconnector_edit_form_provider_validate in OAuth Connector 7

Same name and namespace in other branches
  1. 6 oauthconnector.admin.inc \oauthconnector_edit_form_provider_validate()

Validate submission of the provider edit form.

File

./oauthconnector.admin.inc, line 478
Administrative functions for the OAuth Connector module.

Code

function oauthconnector_edit_form_provider_validate($form, &$form_state) {
  $values = $form_state['values'];
  if (!valid_url($values['url'])) {
    form_error($form['url'], t('The url is not valid.'));
  }
  foreach ($values['mapping']['fields'] as $key => $mapping) {
    if (!empty($mapping['resource']) && !valid_url($mapping['resource'], TRUE)) {
      form_error($form['mapping']['fields'][$key]['resource'], t('The resource is not a valid url.'));
    }
  }

  //TODO: Validate that all resources are either completely filled out or completely empty

  //TODO: Maybe add some more validation? Eg. check for whitespace in empty mappings?

  //TODO: Add triming of eg valid_url() values?
}