Skip to content

Commit 45cf876

Browse files
committed
Add Validation.
1 parent 5c92734 commit 45cf876

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Model/Search/Modifier/Filter/FieldType/MultiSelectFilter.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\FieldType;
1515

1616
use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\SearchModifierInterface;
17+
use ValueError;
1718

1819
final readonly class MultiSelectFilter implements SearchModifierInterface
1920
{
@@ -22,6 +23,7 @@ public function __construct(
2223
private array $values,
2324
private bool $enablePqlFieldNameResolution = true,
2425
) {
26+
$this->validate();
2527
}
2628

2729
public function getField(): string
@@ -38,4 +40,18 @@ public function isPqlFieldNameResolutionEnabled(): bool
3840
{
3941
return $this->enablePqlFieldNameResolution;
4042
}
43+
44+
private function validate(): void
45+
{
46+
foreach ($this->values as $value) {
47+
if (!is_string($value) && !is_int($value) && !is_float($value)) {
48+
throw new ValueError(
49+
sprintf(
50+
'Provided array must contain only string, int or float values. (%s given)',
51+
gettype($value)
52+
),
53+
);
54+
}
55+
}
56+
}
4157
}

0 commit comments

Comments
 (0)