fix search params

This commit is contained in:
Yuri Kuznetsov
2021-05-05 15:43:18 +03:00
parent 3a94ea35f6
commit df294eee15
2 changed files with 16 additions and 16 deletions

View File

@@ -63,11 +63,11 @@ class SearchParamsFetcher
$params['maxSize'] = $request->getQueryParam('maxSize');
$params['offset'] = $request->getQueryParam('offset');
if ($params['maxSize']) {
if (array_key_exists('maxSize', $params)) {
$params['maxSize'] = intval($params['maxSize']);
}
if ($params['offset']) {
if (array_key_exists('offset', $params)) {
$params['offset'] = intval($params['offset']);
}

View File

@@ -251,10 +251,11 @@ class SearchParams
$maxTextAttributeLength = $params['maxTextAttributeLength'] ?? null;
if ($select && !is_array($select)) {
if ($select !== null && !is_array($select)) {
throw new InvalidArgumentException("select should be array.");
}
else if (is_array($select)) {
if (is_array($select)) {
foreach ($select as $item) {
if (!is_string($item)) {
throw new InvalidArgumentException("select has non-string item.");
@@ -262,42 +263,41 @@ class SearchParams
}
}
if ($orderBy && !is_string($orderBy)) {
if ($orderBy !== null && !is_string($orderBy)) {
throw new InvalidArgumentException("orderBy should be string.");
}
if ($order && !is_string($order)) {
if ($order !== null && !is_string($order)) {
throw new InvalidArgumentException("order should be string.");
}
if (!is_array($boolFilterList)) {
throw new InvalidArgumentException("boolFilterList should be array.");
}
else {
foreach ($boolFilterList as $item) {
if (!is_string($item)) {
throw new InvalidArgumentException("boolFilterList has non-string item.");
}
foreach ($boolFilterList as $item) {
if (!is_string($item)) {
throw new InvalidArgumentException("boolFilterList has non-string item.");
}
}
if ($primaryFilter && !is_string($primaryFilter)) {
if ($primaryFilter !== null && !is_string($primaryFilter)) {
throw new InvalidArgumentException("primaryFilter should be string.");
}
if ($textFilter && !is_string($textFilter)) {
if ($textFilter !== null && !is_string($textFilter)) {
throw new InvalidArgumentException("textFilter should be string.");
}
if ($where && !is_array($where)) {
if ($where !== null && !is_array($where)) {
throw new InvalidArgumentException("where should be array.");
}
if ($offset && !is_int($offset)) {
if ($offset !== null && !is_int($offset)) {
throw new InvalidArgumentException("offset should be int.");
}
if ($maxSize && !is_int($maxSize)) {
if ($maxSize !== null && !is_int($maxSize)) {
throw new InvalidArgumentException("maxSize should be int.");
}