Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/Symfony/Component/Validator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.4
---

* Allow single integer for the `versions` option of the `Uuid` constraint

6.3
---

Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Validator/Constraints/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class Uuid extends Constraint
public $normalizer;

/**
* @param int[]|null $versions
* @param int[]|int|null $versions
*/
public function __construct(
array $options = null,
string $message = null,
array $versions = null,
array|int $versions = null,
bool $strict = null,
callable $normalizer = null,
array $groups = null,
Expand All @@ -114,7 +114,7 @@ public function __construct(
parent::__construct($options, $groups, $payload);

$this->message = $message ?? $this->message;
$this->versions = $versions ?? $this->versions;
$this->versions = (array) ($versions ?? $this->versions);
$this->strict = $strict ?? $this->strict;
$this->normalizer = $normalizer ?? $this->normalizer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,13 @@ public static function getUuidForTimeBasedAssertions(): \Generator
yield Uuid::V7_MONOTONIC => ['0184c292-b133-7e10-a3b4-d49c1ab49b2a', true];
yield Uuid::V8_CUSTOM => ['00112233-4455-8677-8899-aabbccddeeff', false];
}

public function testAcceptsSingleIntegerAsVersion()
{
$constraint = new Uuid(versions: 7);

$this->validator->validate('0184c292-b133-7e10-a3b4-d49c1ab49b2a', $constraint);

$this->assertNoViolation();
}
}