You are here

public function FacebookAuthSettingsForm::validateForm in Social Auth Facebook 8.2

Same name and namespace in other branches
  1. 8 src/Form/FacebookAuthSettingsForm.php \Drupal\social_auth_facebook\Form\FacebookAuthSettingsForm::validateForm()
  2. 3.x src/Form/FacebookAuthSettingsForm.php \Drupal\social_auth_facebook\Form\FacebookAuthSettingsForm::validateForm()

File

src/Form/FacebookAuthSettingsForm.php, line 167

Class

FacebookAuthSettingsForm
Settings form for Social Auth Facebook.

Namespace

Drupal\social_auth_facebook\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $graph_version = $form_state
    ->getValue('graph_version');
  if ($graph_version[0] === 'v') {
    $graph_version = substr($graph_version, 1);
    $form_state
      ->setValue('graph_version', $graph_version);
  }
  if (!preg_match('/^[2-9]\\.[0-9]{1,2}$/', $graph_version)) {
    $form_state
      ->setErrorByName('graph_version', $this
      ->t('Invalid API version. The syntax for API version is for example <em>v2.8</em>'));
  }
  parent::validateForm($form, $form_state);
}