Skip to content

Commit ef8b528

Browse files
authored
Adds function type to validator and generate option to HttpQueryContext schema (#167)
1 parent 8b6a4f7 commit ef8b528

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

inc/Config/QueryContext/HttpQueryContext.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,16 @@ class HttpQueryContext implements QueryContextInterface, HttpQueryContextInterfa
5353
'items' => [
5454
'type' => 'object',
5555
'properties' => [
56-
'name' => [ 'type' => 'string' ],
57-
'path' => [ 'type' => 'string' ],
58-
'type' => [ 'type' => 'string' ],
56+
'name' => [ 'type' => 'string' ],
57+
'path' => [
58+
'type' => 'string',
59+
'required' => false,
60+
],
61+
'generate' => [
62+
'type' => 'function',
63+
'required' => false,
64+
],
65+
'type' => [ 'type' => 'string' ],
5966
],
6067
],
6168
],

inc/Validation/Validator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ private function check_type( mixed $value, string $expected_type ): bool {
119119
return is_bool( $value );
120120
case 'null':
121121
return is_null( $value );
122+
case 'function':
123+
return is_callable( $value );
122124
default:
123125
return false;
124126
}

0 commit comments

Comments
 (0)