From f665527c2fad99fab9d624b962d5420450061331 Mon Sep 17 00:00:00 2001
From: Sunny
Date: Mon, 8 Apr 2024 11:27:22 +0700
Subject: [PATCH 1/2] MAKAIRA-4359 Mandatory constraints don't allow empty
string
---
src/AbstractQuery.php | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/AbstractQuery.php b/src/AbstractQuery.php
index 8640e89..28b5117 100644
--- a/src/AbstractQuery.php
+++ b/src/AbstractQuery.php
@@ -69,7 +69,7 @@ public function setConstraint($constraint, $value)
public function verify()
{
foreach ($this->getMandatoryConstraints() as $key => $label) {
- if (!isset($this->constraints[$key])) {
+ if (!$this->isConstraintExists($key)) {
throw new DomainException(sprintf('Missing mandatory %s constraint.', $label));
}
}
@@ -116,4 +116,17 @@ public static function createFromRequest($data)
->verify()
->filterConstraints();
}
+
+ private function isConstraintExists($key)
+ {
+ if (!isset($this->constraints[$key])) {
+ return false;
+ }
+
+ if ('' === $this->constraints[$key]) {
+ return false;
+ }
+
+ return true;
+ }
}
From 80e1735b1c14e1d4ba2ec2a712af91277ceef7d6 Mon Sep 17 00:00:00 2001
From: Sunny
Date: Mon, 8 Apr 2024 14:51:55 +0700
Subject: [PATCH 2/2] MAKAIRA-4359 Apply feedback from PR
---
src/AbstractQuery.php | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/src/AbstractQuery.php b/src/AbstractQuery.php
index 28b5117..9387684 100644
--- a/src/AbstractQuery.php
+++ b/src/AbstractQuery.php
@@ -69,7 +69,7 @@ public function setConstraint($constraint, $value)
public function verify()
{
foreach ($this->getMandatoryConstraints() as $key => $label) {
- if (!$this->isConstraintExists($key)) {
+ if (empty($this->constraints[$key])) {
throw new DomainException(sprintf('Missing mandatory %s constraint.', $label));
}
}
@@ -116,17 +116,4 @@ public static function createFromRequest($data)
->verify()
->filterConstraints();
}
-
- private function isConstraintExists($key)
- {
- if (!isset($this->constraints[$key])) {
- return false;
- }
-
- if ('' === $this->constraints[$key]) {
- return false;
- }
-
- return true;
- }
}