From 67e93a68749311ab99696adda81fa6067021551a Mon Sep 17 00:00:00 2001
From: Alejandro Celaya <alejandro@alejandrocelaya.com>
Date: Fri, 6 Mar 2020 19:20:33 +0100
Subject: [PATCH] Ensured empty values cannot be provided as the custom slug

---
 module/Core/src/Validation/ShortUrlMetaInputFilter.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/module/Core/src/Validation/ShortUrlMetaInputFilter.php b/module/Core/src/Validation/ShortUrlMetaInputFilter.php
index a71b4cc2..604f2648 100644
--- a/module/Core/src/Validation/ShortUrlMetaInputFilter.php
+++ b/module/Core/src/Validation/ShortUrlMetaInputFilter.php
@@ -40,8 +40,11 @@ class ShortUrlMetaInputFilter extends InputFilter
         $validUntil->getValidatorChain()->attach(new Validator\Date(['format' => DateTime::ATOM]));
         $this->add($validUntil);
 
-        $customSlug = $this->createInput(self::CUSTOM_SLUG, false);
+        // FIXME The only way to enforce the NotEmpty validator to be evaluated when the value is provided but it's
+        //       empty, is by using the deprecated setContinueIfEmpty
+        $customSlug = $this->createInput(self::CUSTOM_SLUG, false)->setContinueIfEmpty(true);
         $customSlug->getFilterChain()->attach(new Validation\SluggerFilter());
+        $customSlug->getValidatorChain()->attach(new Validator\NotEmpty());
         $this->add($customSlug);
 
         $this->add($this->createPositiveNumberInput(self::MAX_VISITS));
@@ -58,7 +61,7 @@ class ShortUrlMetaInputFilter extends InputFilter
     {
         $input = $this->createInput($name, false);
         $input->getValidatorChain()->attach(new Validator\Digits())
-              ->attach(new Validator\GreaterThan(['min' => $min, 'inclusive' => true]));
+                                   ->attach(new Validator\GreaterThan(['min' => $min, 'inclusive' => true]));
 
         return $input;
     }