File tree 3 files changed +17
-3
lines changed
src/Symfony/Component/Validator 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=========
3
3
4
+ 6.4
5
+ ---
6
+
7
+ * Allow single integer for the ` versions ` option of the ` Uuid ` constraint
8
+
4
9
6.3
5
10
---
6
11
Original file line number Diff line number Diff line change @@ -100,12 +100,12 @@ class Uuid extends Constraint
100
100
public $ normalizer ;
101
101
102
102
/**
103
- * @param int[]|null $versions
103
+ * @param int[]|int| null $versions
104
104
*/
105
105
public function __construct (
106
106
array $ options = null ,
107
107
string $ message = null ,
108
- array $ versions = null ,
108
+ array | int $ versions = null ,
109
109
bool $ strict = null ,
110
110
callable $ normalizer = null ,
111
111
array $ groups = null ,
@@ -114,7 +114,7 @@ public function __construct(
114
114
parent ::__construct ($ options , $ groups , $ payload );
115
115
116
116
$ this ->message = $ message ?? $ this ->message ;
117
- $ this ->versions = $ versions ?? $ this ->versions ;
117
+ $ this ->versions = ( array ) ( $ versions ?? $ this ->versions ) ;
118
118
$ this ->strict = $ strict ?? $ this ->strict ;
119
119
$ this ->normalizer = $ normalizer ?? $ this ->normalizer ;
120
120
Original file line number Diff line number Diff line change @@ -296,4 +296,13 @@ public static function getUuidForTimeBasedAssertions(): \Generator
296
296
yield Uuid::V7_MONOTONIC => ['0184c292-b133-7e10-a3b4-d49c1ab49b2a ' , true ];
297
297
yield Uuid::V8_CUSTOM => ['00112233-4455-8677-8899-aabbccddeeff ' , false ];
298
298
}
299
+
300
+ public function testAcceptsSingleIntegerAsVersion ()
301
+ {
302
+ $ constraint = new Uuid (versions: 7 );
303
+
304
+ $ this ->validator ->validate ('0184c292-b133-7e10-a3b4-d49c1ab49b2a ' , $ constraint );
305
+
306
+ $ this ->assertNoViolation ();
307
+ }
299
308
}
You can’t perform that action at this time.
0 commit comments