You are here

function wsclient_ui_type_name_validate in Web service client 7

Validation callback for data type names.

1 string reference to 'wsclient_ui_type_name_validate'
wsclient_ui_type in wsclient_ui/wsclient_ui.inc
Data type form.

File

wsclient_ui/wsclient_ui.inc, line 1260
WSClient UI - implements service description management and configuration screens.

Code

function wsclient_ui_type_name_validate($element, &$form_state) {
  if ($element['#value'] && !preg_match('!^[A-Za-z0-9_]+$!', $element['#value'])) {
    form_error($element, t('Data type names must contain only letters, numbers, and underscores.'));
  }
  if ($element['#value'] != $form_state['type']['name'] && isset($form_state['service']->datatypes) && in_array($element['#value'], array_keys($form_state['service']->datatypes))) {
    form_error($element, t('A data type with that name already exists'));
  }
}