Skip to content

Commit

Permalink
Adding numeric type.
Browse files Browse the repository at this point in the history
  • Loading branch information
stratease committed Sep 6, 2024
1 parent 0247d8a commit 8cf8beb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ public function isPropertyTypeValid( string $key, $value ) : bool {
return is_array( $value );
case 'float':
return is_float( $value );
case 'numeric':
return is_numeric( $value );
default:
return $value instanceof $type;
}
Expand Down
1 change: 1 addition & 0 deletions tests/_support/Helper/MockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ class MockModel extends Model {
'lastName' => 'string',
'emails' => [ 'array', [] ],
'microseconds' => 'float',
'number' => 'numeric',
];
}
3 changes: 2 additions & 1 deletion tests/wpunit/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ public function invalidTypeProvider() {
[ 'id', 'Not an integer' ],
[ 'firstName', 100 ],
[ 'emails', 'Not an array' ],
[ 'microseconds', 'Not a float' ]
[ 'microseconds', 'Not a float' ],
[ 'number', 'Not a number' ]
];
}
}

0 comments on commit 8cf8beb

Please sign in to comment.