mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Do not allow bith date older than 100 years
This commit is contained in:
parent
a8205843d9
commit
5a80c45a8d
2 changed files with 6 additions and 1 deletions
|
@ -22,7 +22,7 @@ use WC_Product_Variation;
|
|||
class PayUponInvoiceHelper {
|
||||
|
||||
/**
|
||||
* Ensures date is valid and at least 18 years back.
|
||||
* Ensures date is valid, at least 18 years back and not older than 100 years.
|
||||
*
|
||||
* @param string $date The date.
|
||||
* @param string $format The date format.
|
||||
|
@ -43,6 +43,10 @@ class PayUponInvoiceHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( $date_time < strtotime( '-100 years', time() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class PayUponInvoiceHelperTest extends TestCase
|
|||
['1942-02-31', false],
|
||||
['01-01-1942', false],
|
||||
['1942-01-01', true],
|
||||
['0001-01-01', false],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue