mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
add custom validation get authors path
This commit is contained in:
parent
55e88f2ac6
commit
c2ce516b4d
@ -39,7 +39,7 @@ class GetAuthorsController extends Controller {
|
|||||||
'error' => ERRORS::INVALID_QUERY
|
'error' => ERRORS::INVALID_QUERY
|
||||||
],
|
],
|
||||||
'blackList' => [
|
'blackList' => [
|
||||||
'validation' => DataValidator::oneOf(DataValidator::notBlank(),DataValidator::nullType(),DataValidator::arrayType()),
|
'validation' => DataValidator::oneOf(DataValidator::validBlackList(),DataValidator::nullType()),
|
||||||
'error' => ERRORS::INVALID_BLACK_LIST
|
'error' => ERRORS::INVALID_BLACK_LIST
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
20
server/libs/validations/validBlackList.php
Normal file
20
server/libs/validations/validBlackList.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CustomValidations;
|
||||||
|
|
||||||
|
use Respect\Validation\Rules\AbstractRule;
|
||||||
|
|
||||||
|
class ValidBlackList extends AbstractRule {
|
||||||
|
|
||||||
|
public function validate($blackList) {
|
||||||
|
if(is_array(json_decode($blackList))){
|
||||||
|
foreach (json_decode($blackList) as $item) {
|
||||||
|
if(!$item->id && !$item->staff) return false;
|
||||||
|
if($item->staff !== 0 && $item->staff !== 1) return false;
|
||||||
|
if(!is_numeric($item->id)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user