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
|
||||
],
|
||||
'blackList' => [
|
||||
'validation' => DataValidator::oneOf(DataValidator::notBlank(),DataValidator::nullType(),DataValidator::arrayType()),
|
||||
'validation' => DataValidator::oneOf(DataValidator::validBlackList(),DataValidator::nullType()),
|
||||
'error' => ERRORS::INVALID_BLACK_LIST
|
||||
]
|
||||
]
|
||||
|
|
|
@ -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…
Reference in New Issue