@@ -147,11 +147,13 @@ public function guessTypeForConstraint(Constraint $constraint)
147
147
148
148
case 'Symfony\Component\Validator\Constraints\MaxLength ' :
149
149
case 'Symfony\Component\Validator\Constraints\MinLength ' :
150
+ case 'Symfony\Component\Validator\Constraints\Length ' :
150
151
case 'Symfony\Component\Validator\Constraints\Regex ' :
151
152
return new TypeGuess ('text ' , array (), Guess::LOW_CONFIDENCE );
152
153
153
154
case 'Symfony\Component\Validator\Constraints\Min ' :
154
155
case 'Symfony\Component\Validator\Constraints\Max ' :
156
+ case 'Symfony\Component\Validator\Constraints\Range ' :
155
157
return new TypeGuess ('number ' , array (), Guess::LOW_CONFIDENCE );
156
158
157
159
case 'Symfony\Component\Validator\Constraints\MinCount ' :
@@ -198,6 +200,12 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
198
200
case 'Symfony\Component\Validator\Constraints\MaxLength ' :
199
201
return new ValueGuess ($ constraint ->limit , Guess::HIGH_CONFIDENCE );
200
202
203
+ case 'Symfony\Component\Validator\Constraints\Length ' :
204
+ if (is_numeric ($ constraint ->max )) {
205
+ return new ValueGuess ($ constraint ->max , Guess::HIGH_CONFIDENCE );
206
+ }
207
+ break ;
208
+
201
209
case 'Symfony\Component\Validator\Constraints\Type ' :
202
210
if (in_array ($ constraint ->type , array ('double ' , 'float ' , 'numeric ' , 'real ' ))) {
203
211
return new ValueGuess (null , Guess::MEDIUM_CONFIDENCE );
@@ -206,6 +214,12 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
206
214
207
215
case 'Symfony\Component\Validator\Constraints\Max ' :
208
216
return new ValueGuess (strlen ((string ) $ constraint ->limit ), Guess::LOW_CONFIDENCE );
217
+
218
+ case 'Symfony\Component\Validator\Constraints\Range ' :
219
+ if (is_numeric ($ constraint ->max )) {
220
+ return new ValueGuess (strlen ((string ) $ constraint ->max ), Guess::LOW_CONFIDENCE );
221
+ }
222
+ break ;
209
223
}
210
224
211
225
return null ;
@@ -224,6 +238,12 @@ public function guessPatternForConstraint(Constraint $constraint)
224
238
case 'Symfony\Component\Validator\Constraints\MinLength ' :
225
239
return new ValueGuess (sprintf ('.{%s,} ' , (string ) $ constraint ->limit ), Guess::LOW_CONFIDENCE );
226
240
241
+ case 'Symfony\Component\Validator\Constraints\Length ' :
242
+ if (is_numeric ($ constraint ->min )) {
243
+ return new ValueGuess (sprintf ('.{%s,} ' , (string ) $ constraint ->min ), Guess::LOW_CONFIDENCE );
244
+ }
245
+ break ;
246
+
227
247
case 'Symfony\Component\Validator\Constraints\Regex ' :
228
248
$ htmlPattern = $ constraint ->getHtmlPattern ();
229
249
@@ -235,6 +255,12 @@ public function guessPatternForConstraint(Constraint $constraint)
235
255
case 'Symfony\Component\Validator\Constraints\Min ' :
236
256
return new ValueGuess (sprintf ('.{%s,} ' , strlen ((string ) $ constraint ->limit )), Guess::LOW_CONFIDENCE );
237
257
258
+ case 'Symfony\Component\Validator\Constraints\Range ' :
259
+ if (is_numeric ($ constraint ->min )) {
260
+ return new ValueGuess (sprintf ('.{%s,} ' , strlen ((string ) $ constraint ->min )), Guess::LOW_CONFIDENCE );
261
+ }
262
+ break ;
263
+
238
264
case 'Symfony\Component\Validator\Constraints\Type ' :
239
265
if (in_array ($ constraint ->type , array ('double ' , 'float ' , 'numeric ' , 'real ' ))) {
240
266
return new ValueGuess (null , Guess::MEDIUM_CONFIDENCE );
0 commit comments