Skip to content

Commit 98d710f

Browse files
committed
Fix empty check
1 parent 7e3f523 commit 98d710f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/App.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,6 @@ protected function getArguments(Hook $hook, array $values, array $requestParams)
706706
if (!\is_a($model, Model::class, true)) {
707707
throw new Exception('Model class is not an instance of Utopia\\Model', 500);
708708
}
709-
if (($value === null || $value === '') && $param['optional']) {
710-
$value = null;
711-
}
712709
if (\is_string($value) && $value !== '') {
713710
try {
714711
$value = \json_decode($value, true, flags: JSON_THROW_ON_ERROR);
@@ -726,6 +723,9 @@ protected function getArguments(Hook $hook, array $values, array $requestParams)
726723
throw new Exception('Failed to create model instance for param "' . $key . '": ' . $e->getMessage(), 400);
727724
}
728725
}
726+
if ($param['optional'] && $value === '') {
727+
$value = null;
728+
}
729729
}
730730

731731
if (!$param['skipValidation'] && $paramExists && $value !== null && $value !== '') {

0 commit comments

Comments
 (0)