opensupports/server/libs/validations/validOrderBy.php

20 lines
483 B
PHP
Raw Normal View History

2019-11-10 20:14:30 +01:00
<?php
namespace CustomValidations;
use Respect\Validation\Rules\AbstractRule;
class ValidOrderBy extends AbstractRule {
public function validate($orderBy) {
if(is_object(json_decode($orderBy))){
$values =["closed","owner_id","unread_staff","priority","date"];
2019-12-28 21:50:11 +01:00
2019-11-10 20:14:30 +01:00
$object = json_decode($orderBy);
2019-11-14 21:17:45 +01:00
2019-12-28 21:50:11 +01:00
if(($object->asc !== 1 && $object->asc !== 0) || !in_array($object->value, $values)) return false;
2019-11-14 21:17:45 +01:00
2019-12-28 21:50:11 +01:00
return true;
2019-11-10 20:14:30 +01:00
}
}
2019-11-14 21:17:45 +01:00
}