public function TwilioAdminTestForm::validateForm in Twilio 8
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 FormBase::validateForm
File
- src/Form/ TwilioAdminTestForm.php, line 83 
Class
- TwilioAdminTestForm
- Form to send test SMS messages.
Namespace
Drupal\twilio\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
  $value = $form_state
    ->getValue([
    'number',
  ]);
  if (!is_numeric($value)) {
    $form_state
      ->setErrorByName('number', $this
      ->t('You must enter a phone number'));
  }
  if ($form_state
    ->getValue([
    'mediaUrl',
  ]) && !UrlHelper::isValid($form_state
    ->getValue([
    'mediaUrl',
  ]), TRUE)) {
    $form_state
      ->setErrorByName('mediaUrl', $this
      ->t('Media URL must be a valid, absolute URL.'));
  }
}