public static function CardExpiration::dateIsValid in Creditfield Form Element 8
Simple date check to determine if the expiration date is in the future from right now.
Parameters
$value:
Return value
bool
3 calls to CardExpiration::dateIsValid()
- CardExpiration::validateCardExpiration in src/
Element/ CardExpiration.php - CardExpirationTest::testBadDateValidation in tests/
src/ Unit/ Element/ CardExpirationTest.php - @covers ::dateIsValid @dataProvider providerInvalidCardExpirationDate
- CardExpirationTest::testGoodDateValidation in tests/
src/ Unit/ Element/ CardExpirationTest.php - @covers ::dateIsValid @dataProvider providerValidCardExpirationDate
File
- src/
Element/ CardExpiration.php, line 86
Class
- CardExpiration
- Provides a one-line credit card number field form element.
Namespace
Drupal\creditfield\ElementCode
public static function dateIsValid($value) {
if (!mb_strlen($value)) {
return FALSE;
}
$dateparts = explode('-', $value);
$year = (int) $dateparts[0];
$month = (int) $dateparts[1];
if ($month > 12) {
return FALSE;
}
if ($year < date('Y') || !is_integer($year)) {
return FALSE;
}
if ($year == date('Y') && $month < date('m')) {
return FALSE;
}
return TRUE;
}