Skip to content

Commit

Permalink
fix number cast when post empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
ljxheihei committed May 23, 2024
1 parent 1261251 commit 7bd841a
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 7bd841a

Please sign in to comment.