Skip to content

Commit

Permalink
Adds function type to validator and generate option to HttpQueryConte…
Browse files Browse the repository at this point in the history
…xt schema (#167)
  • Loading branch information
maxschmeling authored Oct 19, 2024
1 parent 8b6a4f7 commit ef8b528
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions inc/Config/QueryContext/HttpQueryContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ class HttpQueryContext implements QueryContextInterface, HttpQueryContextInterfa
'items' => [
'type' => 'object',
'properties' => [
'name' => [ 'type' => 'string' ],
'path' => [ 'type' => 'string' ],
'type' => [ 'type' => 'string' ],
'name' => [ 'type' => 'string' ],
'path' => [
'type' => 'string',
'required' => false,
],
'generate' => [
'type' => 'function',
'required' => false,
],
'type' => [ 'type' => 'string' ],
],
],
],
Expand Down
2 changes: 2 additions & 0 deletions inc/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ private function check_type( mixed $value, string $expected_type ): bool {
return is_bool( $value );
case 'null':
return is_null( $value );
case 'function':
return is_callable( $value );
default:
return false;
}
Expand Down

0 comments on commit ef8b528

Please sign in to comment.