You are here

public function FacebookAuthSettingsForm::validateForm in Social Auth Facebook 3.x

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

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides SocialAuthSettingsForm::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]|[1-9][0-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);
}