Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need the first since it is constructed with 0?

Copy link
Member

@abnegate abnegate Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fogelito It looks like we are using 0 to mean unlimited, so when 0, \count($value) > $this->length won't be checked since 0 == false

return false;
}

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