You are here

public function ValidatorManager::getValidators in Clientside Validation 8

Same name and namespace in other branches
  1. 8.2 src/ValidatorManager.php \Drupal\clientside_validation\ValidatorManager::getValidators()
  2. 3.0.x src/ValidatorManager.php \Drupal\clientside_validation\ValidatorManager::getValidators()
  3. 2.0.x src/ValidatorManager.php \Drupal\clientside_validation\ValidatorManager::getValidators()

Get validators for a form element.

Parameters

array $element: The form element to get the validators for.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the form this element belongs to.

Overrides ValidatorManagerInterface::getValidators

File

src/ValidatorManager.php, line 35

Class

ValidatorManager
Validator plugin manager.

Namespace

Drupal\clientside_validation

Code

public function getValidators(array $element, FormStateInterface $form_state) {
  $instances = [];
  $validators = $this
    ->getDefinitionsForElement($element, $form_state);
  foreach ($validators as $validator) {
    $instances[] = $this
      ->createInstance($validator['id']);
  }
  return $instances;
}