Skip to content

Commit

Permalink
Merge pull request #36 from 123inkt/Update-constraint-list-to-int-key…
Browse files Browse the repository at this point in the history
…-array

Update ConstraintList to int array of Constraint
  • Loading branch information
frankdekker authored May 23, 2023
2 parents 5b26758 + efaa893 commit d514752
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\Validator\Constraint;

/**
* @phpstan-type ConstraintList array<string, string|Constraint|array<string|Constraint>>|Constraint[]
* @phpstan-type ConstraintList array<string, string|Constraint|array<string|Constraint>>|array<int, Constraint>
* @phpstan-type DefinitionCollection array{query?: ConstraintList, request?: ConstraintList, attributes?: ConstraintList }
*/
class ValidationRules
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/ValidationRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Required;

/**
* @coversDefaultClass \DigitalRevolution\SymfonyRequestValidation\ValidationRules
Expand All @@ -24,6 +25,17 @@ public function testConstructorAndGetters(): void
static::assertSame($definitions, $rules->getDefinitions());
}

/**
* @covers ::__construct
* @covers ::getDefinitions
*/
public function testConstructorArrayOfConstraints(): void
{
$definitions = ['query' => [new Required(), new NotBlank()]];
$rules = new ValidationRules($definitions);
static::assertSame($definitions, $rules->getDefinitions());
}

/**
* @covers ::__construct
*/
Expand Down

0 comments on commit d514752

Please sign in to comment.