Ensured BC on dates for short urls params

This commit is contained in:
Alejandro Celaya 2020-01-28 12:57:21 +01:00
parent 51ebe57ac8
commit 7add41d560
2 changed files with 5 additions and 15 deletions

View File

@ -47,7 +47,7 @@
"phly/phly-event-dispatcher": "^1.0", "phly/phly-event-dispatcher": "^1.0",
"predis/predis": "^1.1", "predis/predis": "^1.1",
"pugx/shortid-php": "^0.5", "pugx/shortid-php": "^0.5",
"shlinkio/shlink-common": "^2.5", "shlinkio/shlink-common": "dev-master#e6658205370260df72f295df15364ac569ff702c as 2.6.0",
"shlinkio/shlink-event-dispatcher": "^1.3", "shlinkio/shlink-event-dispatcher": "^1.3",
"shlinkio/shlink-installer": "^4.0.1", "shlinkio/shlink-installer": "^4.0.1",
"shlinkio/shlink-ip-geolocation": "^1.3.1", "shlinkio/shlink-ip-geolocation": "^1.3.1",

View File

@ -4,9 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Validation; namespace Shlinkio\Shlink\Core\Validation;
use DateTime;
use Laminas\Filter; use Laminas\Filter;
use Laminas\InputFilter\ArrayInput;
use Laminas\InputFilter\InputFilter; use Laminas\InputFilter\InputFilter;
use Laminas\Validator; use Laminas\Validator;
use Shlinkio\Shlink\Common\Validation; use Shlinkio\Shlink\Common\Validation;
@ -29,13 +27,8 @@ class ShortUrlsParamsInputFilter extends InputFilter
private function initialize(): void private function initialize(): void
{ {
$startDate = $this->createInput(self::START_DATE, false); $this->add($this->createDateInput(self::START_DATE, false));
$startDate->getValidatorChain()->attach(new Validator\Date(['format' => DateTime::ATOM])); $this->add($this->createDateInput(self::END_DATE, false));
$this->add($startDate);
$endDate = $this->createInput(self::END_DATE, false);
$endDate->getValidatorChain()->attach(new Validator\Date(['format' => DateTime::ATOM]));
$this->add($endDate);
$this->add($this->createInput(self::SEARCH_TERM, false)); $this->add($this->createInput(self::SEARCH_TERM, false));
@ -44,11 +37,8 @@ class ShortUrlsParamsInputFilter extends InputFilter
->attach(new Validator\GreaterThan(['min' => 1, 'inclusive' => true])); ->attach(new Validator\GreaterThan(['min' => 1, 'inclusive' => true]));
$this->add($page); $this->add($page);
$tags = new ArrayInput(self::TAGS); $tags = $this->createArrayInput(self::TAGS, false);
$tags->setRequired(false) $tags->getFilterChain()->attach(new Filter\StringToLower())
->getFilterChain()->attach(new Filter\StripTags())
->attach(new Filter\StringTrim())
->attach(new Filter\StringToLower())
->attach(new Validation\SluggerFilter()); ->attach(new Validation\SluggerFilter());
$this->add($tags); $this->add($tags);
} }