You are here

protected function PaymentMethodEditForm::validateCreditCardForm in Commerce Core 8.2

Validates the credit card form.

Parameters

array $element: The credit card form element.

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

1 call to PaymentMethodEditForm::validateCreditCardForm()
PaymentMethodEditForm::validateConfigurationForm in modules/payment/src/PluginForm/PaymentMethodEditForm.php
Form validation handler.

File

modules/payment/src/PluginForm/PaymentMethodEditForm.php, line 161

Class

PaymentMethodEditForm

Namespace

Drupal\commerce_payment\PluginForm

Code

protected function validateCreditCardForm(array &$element, FormStateInterface $form_state) {
  $values = $form_state
    ->getValue($element['#parents']);
  if (!CreditCard::validateExpirationDate($values['expiration']['month'], $values['expiration']['year'])) {
    $form_state
      ->setError($element['expiration'], t('You have entered an expired credit card.'));
  }
}