Skip to content

Commit 2bf5629

Browse files
minor symfony#24230 [Validator] Clarify UUID validator behavior (ro0NL)
This PR was squashed before being merged into the 2.7 branch (closes symfony#24230). Discussion ---------- [Validator] Clarify UUID validator behavior | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#24209 | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> TLDR; after some investigation this is now a doc update. This fixes the variant detection of a UUID, in strict validation, as described by https://tools.ietf.org/html/rfc4122#section-4.1.1 Tested variant UUID's taken from [ramsey/uuid](https://github.com/ramsey/uuid/blob/master/tests/UuidTest.php#L506). I cannot produce an invalid variant UUID anymore, as i believe by now anything would be variant 3 (future reserved). /cc @backbone87 Commits ------- cde5a47 [Validator] Clarify UUID validator behavior
2 parents 3b42d88 + cde5a47 commit 2bf5629

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@
1818
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1919

2020
/**
21-
* Validates whether the value is a valid UUID per RFC 4122.
21+
* Validates whether the value is a valid UUID (also known as GUID).
22+
*
23+
* Strict validation will allow a UUID as specified per RFC 4122.
24+
* Loose validation will allow any type of UUID.
25+
*
26+
* For better compatibility, both loose and strict, you should consider using a specialized UUID library like "ramsey/uuid" instead.
2227
*
2328
* @author Colin O'Dell <[email protected]>
2429
* @author Bernhard Schussek <[email protected]>
2530
*
2631
* @see http://tools.ietf.org/html/rfc4122
2732
* @see https://en.wikipedia.org/wiki/Universally_unique_identifier
33+
* @see https://github.com/ramsey/uuid
2834
*/
2935
class UuidValidator extends ConstraintValidator
3036
{

0 commit comments

Comments
 (0)