Skip to content

Commit

Permalink
Fixed FileSizeValidator type that caused existing migrations to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
webhdx committed Nov 22, 2023
1 parent bba7da5 commit 22d56db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/FieldType/Image/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Type extends FieldType implements TranslationContainerInterface
protected $validatorConfigurationSchema = [
'FileSizeValidator' => [
'maxFileSize' => [
'type' => 'float',
'type' => 'numeric',
'default' => null,
],
],
Expand Down Expand Up @@ -134,7 +134,7 @@ protected function checkValueStructure(BaseValue $value)
);
}

if (isset($value->fileSize) && (!is_int($value->fileSize) || $value->fileSize < 0)) {
if (isset($value->fileSize) && (!is_float($value->fileSize) || $value->fileSize < 0)) {
throw new InvalidArgumentType(
'$value->fileSize',
'int',
Expand Down Expand Up @@ -233,14 +233,14 @@ public function validateValidatorConfiguration($validatorConfiguration)
);
break;
}
if (!is_float($parameters['maxFileSize']) && $parameters['maxFileSize'] !== null) {
if (!is_numeric($parameters['maxFileSize']) && $parameters['maxFileSize'] !== null) {
$validationErrors[] = new ValidationError(
'Validator %validator% expects parameter %parameter% to be of %type%.',
null,
[
'%validator%' => $validatorIdentifier,
'%parameter%' => 'maxFileSize',
'%type%' => 'float',
'%type%' => 'numeric',
],
"[$validatorIdentifier][maxFileSize]"
);
Expand Down

0 comments on commit 22d56db

Please sign in to comment.