You are here

public function ApiSettingsForm::validateFbAppId in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/ApiSettingsForm.php \Drupal\fb_instant_articles\Form\ApiSettingsForm::validateFbAppId()

Validate the Facebook application id.

Parameters

array $form: FAPI array.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

File

src/Form/ApiSettingsForm.php, line 188

Class

ApiSettingsForm
Facebook Instant Articles API form.

Namespace

Drupal\fb_instant_articles\Form

Code

public function validateFbAppId(array &$form, FormStateInterface $form_state) {
  $app_id = $form_state
    ->getValue('app_id');
  if (empty($app_id)) {
    $form_state
      ->setErrorByName('app_id', $this
      ->t('You must enter the App ID before proceeding.'));
  }
  if (!is_numeric($app_id)) {
    $form_state
      ->setErrorByName('app_id', $this
      ->t('The App ID that you entered is invalid.'));
  }
}