mirror of
https://github.com/opensupports/opensupports.git
synced 2025-04-08 18:35:06 +02:00
21 lines
461 B
PHP
21 lines
461 B
PHP
<?php
|
|
|
|
namespace CustomValidations;
|
|
|
|
use Respect\Validation\Rules\AbstractRule;
|
|
|
|
class ValidDateRange extends AbstractRule {
|
|
|
|
public function validate($dateRange) {
|
|
$dateArray = json_decode($dateRange);
|
|
$counter = 0;
|
|
if(is_array($dateArray)){
|
|
foreach ($dateArray as $date) {
|
|
if (is_numeric($date)) $counter++;
|
|
}
|
|
|
|
return ((sizeof($dateArray) == 2 && $counter == 2) || sizeof($dateArray) == 0 );
|
|
}
|
|
return false;
|
|
}
|
|
} |