Skip to content

Commit

Permalink
Merge pull request #359 from utopia-php/fix-add-length-to-query-valid…
Browse files Browse the repository at this point in the history
…ator

Add check for length in Queries Validator
  • Loading branch information
abnegate authored Nov 28, 2023
2 parents 4691f62 + ef570fd commit ebd030f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Database/Validator/Queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ class Queries extends Validator
*/
protected array $validators;

/**
* @var int
*/
protected int $length;

/**
* Queries constructor
*
* @param array<Base> $validators
*/
public function __construct(array $validators = [])
public function __construct(array $validators = [], int $length = 0)
{
$this->validators = $validators;
$this->length = $length;
}

/**
Expand All @@ -51,6 +57,10 @@ public function isValid($value): bool
return false;
}

if ($this->length && \count($value) > $this->length) {
return false;
}

foreach ($value as $query) {
if (!$query instanceof Query) {
try {
Expand Down

0 comments on commit ebd030f

Please sign in to comment.