8000 feature #38332 [Validator] Add support for UUIDv6 in Uuid constraint … · symfony/symfony@af8ad34 · GitHub
[go: up one dir, main page]

Skip to content

Commit af8ad34

Browse files
committed
feature #38332 [Validator] Add support for UUIDv6 in Uuid constraint (nicolas-grekas)
This PR was merged into the 5.2-dev branch. Discussion ---------- [Validator] Add support for UUIDv6 in Uuid constraint | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #37751 | License | MIT | Doc PR | - Commits ------- 55c17e1 [Validator] Add support for UUIDv6 in Uuid constraint
2 parents d5ce0e3 + 55c17e1 commit af8ad34

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ CHANGELOG
3131
```
3232
* added the `Isin` constraint and validator
3333
* added the `ULID` constraint and validator
34+
* added support for UUIDv6 in `Uuid` constraint
3435

3536
5.1.0
3637
-----

src/Symfony/Component/Validator/Constraints/Uuid.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Uuid extends Constraint
4444
const V3_MD5 = 3;
4545
const V4_RANDOM = 4;
4646
const V5_SHA1 = 5;
47+
const V6_SORTABLE = 6;
4748

4849
/**
4950
* Message to display when validation fails.
@@ -74,6 +75,7 @@ class Uuid extends Constraint
7475
self::V3_MD5,
7576
self::V4_RANDOM,
7677
self::V5_SHA1,
78+
self::V6_SORTABLE,
7779
];
7880

7981
public $normalizer;

src/Symfony/Component/Validator/Constraints/UuidValidator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
* Strict validation will allow a UUID as specified per RFC 4122.
2323
* Loose validation will allow any type of UUID.
2424
*
25-
* For better compatibility, both loose and strict, you should consider using a specialized UUID library like "ramsey/uuid" instead.
26-
*
2725
* @author Colin O'Dell <colinodell@gmail.com>
2826
* @author Bernhard Schussek <bschussek@gmail.com>
2927
*
3028
* @see http://tools.ietf.org/html/rfc4122
3129
* @see https://en.wikipedia.org/wiki/Universally_unique_identifier
32-
* @see https://github.com/ramsey/uuid
3330
*/
3431
class UuidValidator extends ConstraintValidator
3532
{
@@ -38,7 +35,7 @@ class UuidValidator extends ConstraintValidator
3835

3936
// Roughly speaking:
4037
// x = any hexadecimal character
41-
// M = any allowed version {1..5}
38+
// M = any allowed version {1..6}
4239
// N = any allowed variant {8, 9, a, b}
4340

4441
const STRICT_LENGTH = 36;

src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function getValidStrictUuids()
7878
['456daefb-5aa6-41b5-8dbc-068b05a8b201'], // Version 4 UUID in lowercase
7979
['456daEFb-5AA6-41B5-8DBC-068B05A8B201'], // Version 4 UUID in mixed case
8080
['456daEFb-5AA6-41B5-8DBC-068B05A8B201', [Uuid::V4_RANDOM]],
81+
['1eb01932-4c0b-6570-aa34-d179cdf481ae', [Uuid::V6_SORTABLE]],
8182
];
8283
}
8384

@@ -145,7 +146,6 @@ public function getInvalidStrictUuids()
145146
['216fff40-98d9-11e3-a5e2-0800200c9a6', Uuid::TOO_SHORT_ERROR],
146147
['216fff40-98d9-11e3-a5e2-0800200c9a666', Uuid::TOO_LONG_ERROR],
147148
['216fff40-98d9-01e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
148-
['216fff40-98d9-61e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
149149
['216fff40-98d9-71e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
150150
['216fff40-98d9-81e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],
151151
['216fff40-98d9-91e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],

0 commit comments

Comments
 (0)
0