Skip to content

Commit

Permalink
Merge pull request #76 from szutoutou/szutoutou-fix
Browse files Browse the repository at this point in the history
fix number cast when post empty string
  • Loading branch information
WendellAdriel committed May 28, 2024
2 parents 1261251 + 7bd841a commit 6b9b239
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Casting/FloatCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class FloatCast implements Castable
*/
public function cast(string $property, mixed $value): float
{
if (! is_numeric($value)) {
if (! is_numeric($value) && $value !== '') {
throw new CastException($property);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Casting/IntegerCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class IntegerCast implements Castable
*/
public function cast(string $property, mixed $value): int
{
if (! is_numeric($value)) {
if (! is_numeric($value) && $value !== '') {
throw new CastException($property);
}

Expand Down

0 comments on commit 6b9b239

Please sign in to comment.