Skip to content

Commit 304b72f

Browse files
[Uid] Add UuidV7 and UuidV8
1 parent ec7943b commit 304b72f

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Constraints/Uuid.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class Uuid extends Constraint
5151
public const V4_RANDOM = 4;
5252
public const V5_SHA1 = 5;
5353
public const V6_SORTABLE = 6;
54+
public const V7_SORTABLE = 7;
55+
public const V8_CUSTOM = 8;
5456

5557
public const ALL_VERSIONS = [
5658
self::V1_MAC,
@@ -59,6 +61,8 @@ class Uuid extends Constraint
5961
self::V4_RANDOM,
6062
self::V5_SHA1,
6163
self::V6_SORTABLE,
64+
self::V7_SORTABLE,
65+
self::V8_CUSTOM,
6266
];
6367

6468
/**

Constraints/UuidValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class UuidValidator extends ConstraintValidator
3535

3636
// Roughly speaking:
3737
// x = any hexadecimal character
38-
// M = any allowed version {1..6}
38+
// M = any allowed version {1..8}
3939
// N = any allowed variant {8, 9, a, b}
4040

4141
public const STRICT_LENGTH = 36;

Tests/Constraints/UuidValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public function getValidStrictUuids()
8282
['456daEFb-5AA6-41B5-8DBC-068B05A8B201'], // Version 4 UUID in mixed case
8383
['456daEFb-5AA6-41B5-8DBC-068B05A8B201', [Uuid::V4_RANDOM]],
8484
['1eb01932-4c0b-6570-aa34-d179cdf481ae', [Uuid::V6_SORTABLE]],
85+
['216fff40-98d9-71e3-a5e2-0800200c9a66', [Uuid::V7_SORTABLE]],
86+
['216fff40-98d9-81e3-a5e2-0800200c9a66', [Uuid::V8_CUSTOM]],
8587
];
8688
}
8789

@@ -159,8 +161,6 @@ public function getInvalidStrictUuids()
159161
['216fff40-98d9-11e3-a5e2-0800200c9a6', Uuid::TOO_SHORT_ERROR],
160162
['216fff40-98d9-11e3-a5e2-0800200c9a666', Uuid::TOO_LONG_ERROR],
161163
['216fff40-98d9-01e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
162-
['216fff40-98d9-71e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
163-
['216fff40-98d9-81e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
164164
['216fff40-98d9-91e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
165165
['216fff40-98d9-a1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
166166
['216fff40-98d9-b1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],

0 commit comments

Comments
 (0)