8000 [Validator] Allow single integer for the `versions` option of the `Uuid` constraint by alexandre-daubois · Pull Request #50396 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Allow single integer for the versions option of the Uuid constraint #50396

New issue

Have a question about this project? Sign up fo 8000 r a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
< 8000 span class="BtnGroup min-width-0 flex-self-center">
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();
}
}
0