public static function CreditCard::validateExpirationDate in Commerce Core 8.2
Validates the given credit card expiration date.
Parameters
string $month: The 1 or 2-digit numeric representation of the month, i.e. 1, 6, 12.
string $year: The 4-digit numeric representation of the year, i.e. 2010.
Return value
bool TRUE if the credit card expiration date is valid, FALSE otherwise.
3 calls to CreditCard::validateExpirationDate()
- CreditCardTest::testValidateExpirationDate in modules/
payment/ tests/ src/ Unit/ CreditCardTest.php - @covers ::validateExpirationDate @dataProvider expirationDateProvider
- PaymentMethodAddForm::validateCreditCardForm in modules/
payment/ src/ PluginForm/ PaymentMethodAddForm.php - Validates the credit card form.
- PaymentMethodEditForm::validateCreditCardForm in modules/
payment/ src/ PluginForm/ PaymentMethodEditForm.php - Validates the credit card form.
File
- modules/
payment/ src/ CreditCard.php, line 222
Class
- CreditCard
- Provides logic for listing card types and validating card details.
Namespace
Drupal\commerce_paymentCode
public static function validateExpirationDate(string $month, string $year) : bool {
if ($month < 1 || $month > 12) {
return FALSE;
}
if ($year < date('Y')) {
return FALSE;
}
elseif ($year == date('Y') && $month < date('n')) {
return FALSE;
}
return TRUE;
}