From 08b5841b8a208882a8e81b168a20fe16aad52470 Mon Sep 17 00:00:00 2001 From: Xenofon Spafaridis Date: Fri, 12 Feb 2016 20:48:09 +0200 Subject: [PATCH] Page directive limit can be null|integer >= 1 --- src/Filter.php | 4 ++-- src/Page.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Filter.php b/src/Filter.php index 5f030fe..bb3f212 100644 --- a/src/Filter.php +++ b/src/Filter.php @@ -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 )); diff --git a/src/Page.php b/src/Page.php index d566487..666b19b 100644 --- a/src/Page.php +++ b/src/Page.php @@ -26,6 +26,7 @@ * @author Xenofon Spafaridis * @property-read int|null $limit * @property-read int $offset + * @todo add validate method */ class Page implements \JsonSerializable { @@ -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 @@ -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']); }