opensupports/server/libs/validations/validAuthorsId.php
LautaroCesso 52eae4d242
Thorough ruby tests /ticket/search path (#870)
* Add ticket/search test (ruby)

* Resolve github maxi comments.

* Resolve github maxi comments second part.

* wip

* Rename some test.

* Add query filter test.

* Add test combining multiple parameters.

* wip

* comment query test in search.rb

* comment query test in search.rb second part.
2020-08-28 05:19:47 -03:00

24 lines
574 B
PHP

<?php
namespace CustomValidations;
use Respect\Validation\Rules\AbstractRule;
class ValidAuthorsId extends AbstractRule {
public function validate($authors) {
if(is_array(json_decode($authors))){
foreach (json_decode($authors) as $authorObject) {
if(!is_object($authorObject)) return false;
if($authorObject->isStaff) {
$author = \Staff::getDataStore($authorObject->id);
} else {
$author = \User::getDataStore($authorObject->id);
}
if($author->isNull()) return false;
}
return true;
}
return false;
}
}