You are here

public static function CpfCnpjBase::validateElement in Brazilian IDs 8

Validates the CNPJ value.

File

src/Element/CpfCnpjBase.php, line 88

Class

CpfCnpjBase
Base class for CPF and CNPJ elements.

Namespace

Drupal\brazilian_ids\Element

Code

public static function validateElement(&$element, FormStateInterface $form_state, &$complete_form) {
  $value = $element['#value'];
  $error = [];
  if ($value !== '' && !static::validateValue($value, $error)) {
    $form_state
      ->setError($element, $error['message']);
  }
}