diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index b77219de92..043f310f35 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -31,6 +31,7 @@ CHANGELOG ``` * added the `Isin` constraint and validator * added the `ULID` constraint and validator + * added support for UUIDv6 in `Uuid` constraint 5.1.0 ----- diff --git a/src/Symfony/Component/Validator/Constraints/Uuid.php b/src/Symfony/Component/Validator/Constraints/Uuid.php index 80cbf609e5..e43b04e4a5 100644 --- a/src/Symfony/Component/Validator/Constraints/Uuid.php +++ b/src/Symfony/Component/Validator/Constraints/Uuid.php @@ -44,6 +44,7 @@ class Uuid extends Constraint const V3_MD5 = 3; const V4_RANDOM = 4; const V5_SHA1 = 5; + const V6_SORTABLE = 6; /** * Message to display when validation fails. @@ -74,6 +75,7 @@ class Uuid extends Constraint self::V3_MD5, self::V4_RANDOM, self::V5_SHA1, + self::V6_SORTABLE, ]; public $normalizer; diff --git a/src/Symfony/Component/Validator/Constraints/UuidValidator.php b/src/Symfony/Component/Validator/Constraints/UuidValidator.php index 49bdf8765a..f3acc86122 100644 --- a/src/Symfony/Component/Validator/Constraints/UuidValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UuidValidator.php @@ -22,14 +22,11 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; * Strict validation will allow a UUID as specified per RFC 4122. * Loose validation will allow any type of UUID. * - * For better compatibility, both loose and strict, you should consider using a specialized UUID library like "ramsey/uuid" instead. - * * @author Colin O'Dell * @author Bernhard Schussek * * @see http://tools.ietf.org/html/rfc4122 * @see https://en.wikipedia.org/wiki/Universally_unique_identifier - * @see https://github.com/ramsey/uuid */ class UuidValidator extends ConstraintValidator { @@ -38,7 +35,7 @@ class UuidValidator extends ConstraintValidator // Roughly speaking: // x = any hexadecimal character - // M = any allowed version {1..5} + // M = any allowed version {1..6} // N = any allowed variant {8, 9, a, b} const STRICT_LENGTH = 36; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php index b6d5fb3dba..e9d1575b8b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php @@ -78,6 +78,7 @@ class UuidValidatorTest extends ConstraintValidatorTestCase ['456daefb-5aa6-41b5-8dbc-068b05a8b201'], // Version 4 UUID in lowercase ['456daEFb-5AA6-41B5-8DBC-068B05A8B201'], // Version 4 UUID in mixed case ['456daEFb-5AA6-41B5-8DBC-068B05A8B201', [Uuid::V4_RANDOM]], + ['1eb01932-4c0b-6570-aa34-d179cdf481ae', [Uuid::V6_SORTABLE]], ]; } @@ -145,7 +146,6 @@ class UuidValidatorTest extends ConstraintValidatorTestCase ['216fff40-98d9-11e3-a5e2-0800200c9a6', Uuid::TOO_SHORT_ERROR], ['216fff40-98d9-11e3-a5e2-0800200c9a666', Uuid::TOO_LONG_ERROR], ['216fff40-98d9-01e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR], - ['216fff40-98d9-61e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR], ['216fff40-98d9-71e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR], ['216fff40-98d9-81e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR], ['216fff40-98d9-91e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR],