Skip to content

Commit

Permalink
[Validator] Added support for validation of giga values
Browse files Browse the repository at this point in the history
  • Loading branch information
kernig authored and fabpot committed Jul 19, 2019
1 parent 0349294 commit 969f2c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Symfony/Component/Validator/Constraints/File.php
Expand Up @@ -102,8 +102,10 @@ private function normalizeBinaryFormat($maxSize)
$factors = [
'k' => 1000,
'ki' => 1 << 10,
'm' => 1000000,
'm' => 1000 * 1000,
'mi' => 1 << 20,
'g' => 1000 * 1000 * 1000,
'gi' => 1 << 30,
];
if (ctype_digit((string) $maxSize)) {
$this->maxSize = (int) $maxSize;
Expand Down
Expand Up @@ -97,6 +97,10 @@ public function provideValidSizes()
['1MI', 1048576, true],
['3m', 3000000, false],
['3M', 3000000, false],
['1gi', 1073741824, true],
['1GI', 1073741824, true],
['4g', 4000000000, false],
['4G', 4000000000, false],
];
}

Expand All @@ -107,8 +111,6 @@ public function provideInvalidSizes()
['foo'],
['1Ko'],
['1kio'],
['1G'],
['1Gi'],
];
}

Expand Down

0 comments on commit 969f2c4

Please sign in to comment.