Skip to content

Commit 676dff6

Browse files
feat: improves data casting
Co-authored-by: Jon Waldstein <Jpwaldstein@gmail.com>
1 parent a7c7c3b commit 676dff6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Models/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ protected static function castValueForProperty( string $type, $value, string $pr
8080
case 'string':
8181
return (string) $value;
8282
case 'bool':
83-
return (bool) $value;
83+
return (bool)filter_var($value, FILTER_VALIDATE_BOOLEAN);
8484
case 'array':
8585
return (array) $value;
8686
case 'float':
87-
return (float) $value;
87+
return (float)filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
8888
default:
8989
Config::throwInvalidArgumentException( "Unexpected type: '$type'. To support additional types, implement a custom castValueForProperty() method." );
9090
}

0 commit comments

Comments
 (0)