Skip to content

Commit

Permalink
Page directive limit can be null|integer >= 1
Browse files Browse the repository at this point in the history
  • Loading branch information
nohponex committed Feb 12, 2016
1 parent 30b6ee0 commit 08b5841
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ public function validate($modelClass)
}

//Check if operator is allowed
if (!in_array(
if (!$isJSONFilter && !in_array(
$filterAttribute->operator,
Operator::getByClassFlags($operatorClass)
)) {
throw new RequestException(sprintf(
'Filter operator "%" is not allowed for attribute "%s"',
'Filter operator "%s" is not allowed for attribute "%s"',
$filterAttribute->operator,
$filterAttribute->attribute
));
Expand Down
5 changes: 3 additions & 2 deletions src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @author Xenofon Spafaridis <nohponex@gmail.com>
* @property-read int|null $limit
* @property-read int $offset
* @todo add validate method
*/
class Page implements \JsonSerializable
{
Expand Down Expand Up @@ -58,7 +59,7 @@ public function __construct($limit = null, $offset = 0)
* $page = Page::parseFromParameters(
* (object) [
* 'page' => [
* 'limit' => 0,
* 'limit' => 1,
* 'offset' => 0
* ]
* ], //Request parameters object
Expand All @@ -83,7 +84,7 @@ public static function parseFromParameters($parameters, $modelClass)

if (isset($parameters->page['limit'])) {
$limit =
(new UnsignedIntegerValidator())
(new UnsignedIntegerValidator(1))
->parse($parameters->page['limit']);
}

Expand Down

0 comments on commit 08b5841

Please sign in to comment.