You are here

public function EmailContactInlineFormatter::validateCustomPath in Email Contact 8

File

src/Plugin/Field/FieldFormatter/EmailContactInlineFormatter.php, line 133

Class

EmailContactInlineFormatter
Plugin implementation of the 'email_contact_inline' formatter.

Namespace

Drupal\email_contact\Plugin\Field\FieldFormatter

Code

public function validateCustomPath($element, FormStateInterface $form_state) {
  $settings = $this
    ->getSettings();
  if ('custom' == $settings['redirection_to']) {
    if (empty($element['#value'])) {
      $form_state
        ->setError($element, $this
        ->t('The custom path is required!'));
    }
    if (!UrlHelper::isValid($element['#value'])) {
      $form_state
        ->setError($element, $this
        ->t('The given url is not valid!'));
    }
  }
}