8000 bug #45870 [Validator] Fix File constraint invalid max size exception… · symfony/symfony@780efff · GitHub
[go: up one dir, main page]

Skip to content

Commit 780efff

Browse files
bug #45870 [Validator] Fix File constraint invalid max size exception message (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] Fix File constraint invalid max size exception message | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | - | Tickets | - | License | MIT | Doc PR | - Commits ------- a9e781f [Validator] Fix File constraint invalid max size exception message
2 parents 7b43f0f + a9e781f commit 780efff

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/Validator/Constraints/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function normalizeBinaryFormat($maxSize)
117117
$this->maxSize = $matches[1] * $factors[$unit = strtolower($matches[2])];
118118
$this->binaryFormat = $this->binaryFormat ?? (2 === \strlen($unit));
119119
} else {
120-
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size.', $this->maxSize));
120+
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size.', $maxSize));
121121
}
122122
}
123123
}

src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,5 +479,14 @@ public function uploadedFileErrorProvider()
479479
return $tests;
480480
}
481481

482+
public function testNegativeMaxSize()
483+
{
484+
$this->expectException(ConstraintDefinitionException::class);
485+
$this->expectExceptionMessage('"-1" is not a valid maximum size.');
486+
487+
$file = new File();
488+
$file->maxSize = -1;
489+
}
490+
482491
abstract protected function getFile($filename);
483492
}

0 commit comments

Comments
 (0)
0