Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c05232f

Browse filesBrowse files
committed
bug #9135 [Form] [Validator] fix maxLength guesser (franek)
This PR was merged into the 2.3 branch. Discussion ---------- [Form] [Validator] fix maxLength guesser | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9132 | License | MIT | Doc PR | - [ ] need to add unit tests on ValidatorTypeGuesser.php Commits ------- f232550 remove deprecated constraints calls (Min, Max, MaxLength, MinLength)
2 parents eccd938 + f232550 commit c05232f
Copy full SHA for c05232f

File tree

Expand file treeCollapse file tree

1 file changed

+0
-16
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+0
-16
lines changed

‎src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,10 @@ public function guessTypeForConstraint(Constraint $constraint)
145145
case 'Symfony\Component\Validator\Constraints\Ip':
146146
return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE);
147147

148-
case 'Symfony\Component\Validator\Constraints\MaxLength':
149-
case 'Symfony\Component\Validator\Constraints\MinLength':
150148
case 'Symfony\Component\Validator\Constraints\Length':
151149
case 'Symfony\Component\Validator\Constraints\Regex':
152150
return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE);
153151

154-
case 'Symfony\Component\Validator\Constraints\Min':
155-
case 'Symfony\Component\Validator\Constraints\Max':
156152
case 'Symfony\Component\Validator\Constraints\Range':
157153
return new TypeGuess('number', array(), Guess::LOW_CONFIDENCE);
158154

@@ -196,9 +192,6 @@ public function guessRequiredForConstraint(Constraint $constraint)
196192
public function guessMaxLengthForConstraint(Constraint $constraint)
197193
{
198194
switch (get_class($constraint)) {
199-
case 'Symfony\Component\Validator\Constraints\MaxLength':
200-
return new ValueGuess($constraint->limit, Guess::HIGH_CONFIDENCE);
201-
202195
case 'Symfony\Component\Validator\Constraints\Length':
203196
if (is_numeric($constraint->max)) {
204197
return new ValueGuess($constraint->max, Guess::HIGH_CONFIDENCE);
@@ -211,9 +204,6 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
211204
}
212205
break;
213206

214-
case 'Symfony\Component\Validator\Constraints\Max':
215-
return new ValueGuess(strlen((string) $constraint->limit), Guess::LOW_CONFIDENCE);
216-
217207
case 'Symfony\Component\Validator\Constraints\Range':
218208
if (is_numeric($constraint->max)) {
219209
return new ValueGuess(strlen((string) $constraint->max), Guess::LOW_CONFIDENCE);
@@ -234,9 +224,6 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
234224
public function guessPatternForConstraint(Constraint $constraint)
235225
{
236226
switch (get_class($constraint)) {
237-
case 'Symfony\Component\Validator\Constraints\MinLength':
238-
return new ValueGuess(sprintf('.{%s,}', (string) $constraint->limit), Guess::LOW_CONFIDENCE);
239-
240227
case 'Symfony\Component\Validator\Constraints\Length':
241228
if (is_numeric($constraint->min)) {
242229
return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE);
@@ -251,9 +238,6 @@ public function guessPatternForConstraint(Constraint $constraint)
251238
}
252239
break;
253240

254-
case 'Symfony\Component\Validator\Constraints\Min':
255-
return new ValueGuess(sprintf('.{%s,}', strlen((string) $constraint->limit)), Guess::LOW_CONFIDENCE);
256-
257241
case 'Symfony\Component\Validator\Constraints\Range':
258242
if (is_numeric($constraint->min)) {
259243
return new ValueGuess(sprintf('.{%s,}', strlen((string) $constraint->min)), Guess::LOW_CONFIDENCE);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.