@@ -155,11 +155,13 @@ public function guessTypeForConstraint(Constraint $constraint)
155
155
156
156
case 'Symfony\Component\Validator\Constraints\MaxLength ' :
157
157
case 'Symfony\Component\Validator\Constraints\MinLength ' :
158
+ case 'Symfony\Component\Validator\Constraints\Length ' :
158
159
case 'Symfony\Component\Validator\Constraints\Regex ' :
159
160
return new TypeGuess ('text ' , array (), Guess::LOW_CONFIDENCE );
160
161
161
162
case 'Symfony\Component\Validator\Constraints\Min ' :
162
163
case 'Symfony\Component\Validator\Constraints\Max ' :
164
+ case 'Symfony\Component\Validator\Constraints\Range ' :
163
165
return new TypeGuess ('number ' , array (), Guess::LOW_CONFIDENCE );
164
166
165
167
case 'Symfony\Component\Validator\Constraints\MinCount ' :
@@ -206,6 +208,12 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
206
208
case 'Symfony\Component\Validator\Constraints\MaxLength ' :
207
209
return new ValueGuess ($ constraint ->limit , Guess::HIGH_CONFIDENCE );
208
210
211
+ case 'Symfony\Component\Validator\Constraints\Length ' :
212
+ if (is_numeric ($ constraint ->max )) {
213
+ return new ValueGuess ($ constraint ->max , Guess::HIGH_CONFIDENCE );
214
+ }
215
+ break ;
216
+
209
217
case 'Symfony\Component\Validator\Constraints\Type ' :
210
218
if (in_array ($ constraint ->type , array ('double ' , 'float ' , 'numeric ' , 'real ' ))) {
211
219
return new ValueGuess (null , Guess::MEDIUM_CONFIDENCE );
@@ -214,6 +222,12 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
214
222
215
223
case 'Symfony\Component\Validator\Constraints\Max ' :
216
224
return new ValueGuess (strlen ((string ) $ constraint ->limit ), Guess::LOW_CONFIDENCE );
225
+
226
+ case 'Symfony\Component\Validator\Constraints\Range ' :
227
+ if (is_numeric ($ constraint ->max )) {
228
+ return new ValueGuess (strlen ((string ) $ constraint ->max ), Guess::LOW_CONFIDENCE );
229
+ }
230
+ break ;
217
231
}
218
232
219
233
return null ;
@@ -232,6 +246,12 @@ public function guessPatternForConstraint(Constraint $constraint)
232
246
case 'Symfony\Component\Validator\Constraints\MinLength ' :
233
247
return new ValueGuess (sprintf ('.{%s,} ' , (string ) $ constraint ->limit ), Guess::LOW_CONFIDENCE );
234
248
249
+ case 'Symfony\Component\Validator\Constraints\Length ' :
250
+ if (is_numeric ($ constraint ->min )) {
251
+ return new ValueGuess (sprintf ('.{%s,} ' , (string ) $ constraint ->min ), Guess::LOW_CONFIDENCE );
252
+ }
253
+ break ;
254
+
235
255
case 'Symfony\Component\Validator\Constraints\Regex ' :
236
256
$ htmlPattern = $ constraint ->getHtmlPattern ();
237
257
@@ -243,6 +263,12 @@ public function guessPatternForConstraint(Constraint $constraint)
243
263
case 'Symfony\Component\Validator\Constraints\Min ' :
244
264
return new ValueGuess (sprintf ('.{%s,} ' , strlen ((string ) $ constraint ->limit )), Guess::LOW_CONFIDENCE );
245
265
266
+ case 'Symfony\Component\Validator\Constraints\Range ' :
267
+ if (is_numeric ($ constraint ->min )) {
268
+ return new ValueGuess (sprintf ('.{%s,} ' , strlen ((string ) $ constraint ->min )), Guess::LOW_CONFIDENCE );
269
+ }
270
+ break ;
271
+
246
272
case 'Symfony\Component\Validator\Constraints\Type ' :
247
273
if (in_array ($ constraint ->type , array ('double ' , 'float ' , 'numeric ' , 'real ' ))) {
248
274
return new ValueGuess (null , Guess::MEDIUM_CONFIDENCE );
0 commit comments