You are here

function _addthis_display_element_validate_services in AddThis 7.4

Validate the services text field to validate if services are correct.

1 string reference to '_addthis_display_element_validate_services'
addthis_displays_field_formatter_settings_form in addthis_displays/addthis_displays.field.inc
Implementss hook_field_formatter_settings_form().

File

addthis_displays/addthis_displays.field.inc, line 112
Defines field implementations.

Code

function _addthis_display_element_validate_services($element, &$form_state, $form) {
  $bad = FALSE;
  $services = trim($element['#value']);
  $services = str_replace(' ', '', $services);
  if (!preg_match('/^[a-z\\_\\,0-9]+$/', $services)) {
    $bad = TRUE;
  }

  // @todo Validate the service names against AddThis.com. Give a notice when there are bad names.
  // Return error.
  if ($bad) {
    form_error($element, t('The declared services are incorrect or nonexistent.'));
  }
}