You are here

public function DisclaimerBlock::blockValidate in Disclaimer 8

Overrides BlockPluginTrait::blockValidate

File

src/Plugin/Block/DisclaimerBlock.php, line 173

Class

DisclaimerBlock
Provides a 'DisclaimerBlock' block.

Namespace

Drupal\disclaimer\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) {
  $url_object = $this->pathValidator
    ->getUrlIfValid($form_state
    ->getValue('redirect'));
  if (!$url_object) {
    $form_state
      ->setErrorByName('redirect', $this
      ->t('Redirect URL must be valid path.'));
  }
  if (!preg_match('/^[0-9]+$/', $form_state
    ->getValue('max_age'))) {
    $form_state
      ->setErrorByName('max_age', $this
      ->t('Max-age must be integer.'));
  }
}