[Validator] Added support for validation of giga values
This commit is contained in:
parent
0349294175
commit
969f2c4a81
@ -102,8 +102,10 @@ class File extends Constraint
|
|||||||
$factors = [
|
$factors = [
|
||||||
'k' => 1000,
|
'k' => 1000,
|
||||||
'ki' => 1 << 10,
|
'ki' => 1 << 10,
|
||||||
'm' => 1000000,
|
'm' => 1000 * 1000,
|
||||||
'mi' => 1 << 20,
|
'mi' => 1 << 20,
|
||||||
|
'g' => 1000 * 1000 * 1000,
|
||||||
|
'gi' => 1 << 30,
|
||||||
];
|
];
|
||||||
if (ctype_digit((string) $maxSize)) {
|
if (ctype_digit((string) $maxSize)) {
|
||||||
$this->maxSize = (int) $maxSize;
|
$this->maxSize = (int) $maxSize;
|
||||||
|
@ -97,6 +97,10 @@ class FileTest extends TestCase
|
|||||||
['1MI', 1048576, true],
|
['1MI', 1048576, true],
|
||||||
['3m', 3000000, false],
|
['3m', 3000000, false],
|
||||||
['3M', 3000000, false],
|
['3M', 3000000, false],
|
||||||
|
['1gi', 1073741824, true],
|
||||||
|
['1GI', 1073741824, true],
|
||||||
|
['4g', 4000000000, false],
|
||||||
|
['4G', 4000000000, false],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +111,6 @@ class FileTest extends TestCase
|
|||||||
['foo'],
|
['foo'],
|
||||||
['1Ko'],
|
['1Ko'],
|
||||||
['1kio'],
|
['1kio'],
|
||||||
['1G'],
|
|
||||||
['1Gi'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user