You are here

public function FilesExtractor::validateConfigurationForm in Search API attachments 9.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/processor/FilesExtractor.php \Drupal\search_api_attachments\Plugin\search_api\processor\FilesExtractor::validateConfigurationForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

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

Overrides PluginFormInterface::validateConfigurationForm

See also

\Drupal\Core\Plugin\PluginFormInterface::validateConfigurationForm()

File

src/Plugin/search_api/processor/FilesExtractor.php, line 586

Class

FilesExtractor
Provides file fields processor.

Namespace

Drupal\search_api_attachments\Plugin\search_api\processor

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

  // Validate 'number_first_bytes'.
  $number_first_bytes = trim($form_state
    ->getValue('number_first_bytes'));
  $error = $this
    ->validateSize($number_first_bytes);
  if ($error) {
    $form_state
      ->setError($form['number_first_bytes'], $this
      ->t('The size limit option must contain a valid value. You may either enter "0" (for no restriction) or a string like "10 KB", "10 MB" or "10 GB".'));
  }

  // Validate 'max_filesize'.
  $max_filesize = trim($form_state
    ->getValue('max_filesize'));
  $error = $this
    ->validateSize($max_filesize);
  if ($error) {
    $form_state
      ->setError($form['max_filesize'], $this
      ->t('The max filesize option must contain a valid value. You may either enter "0" (for no restriction) or a string like "10 KB", "10 MB" or "10 GB".'));
  }
}