opensupports/server/libs/validations/validDateRange.php

21 lines
488 B
PHP
Raw Normal View History

2019-11-10 20:14:30 +01:00
<?php
namespace CustomValidations;
use Respect\Validation\Rules\AbstractRule;
class ValidDateRange extends AbstractRule {
public function validate($dateRange) {
2019-12-28 21:50:11 +01:00
$dateArray = json_decode($dateRange);
2019-12-29 19:48:57 +01:00
if(is_array($dateArray) && count($dateArray) == 2 ){
2019-12-28 21:50:11 +01:00
foreach ($dateArray as $date) {
if (!is_numeric($date)) return false;
}
return $dateArray[0] <= $dateArray[1];
}
return false;
}
}