File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change
1
+ const PUBLISHER_ID_MIN_LENGTH = 1 ;
2
+ const PUBLISHER_ID_MAX_LENGTH = 50 ;
3
+
1
4
function validateQuery ( query , schema ) {
2
5
if ( query == null ) {
3
6
throw new Error ( 'Invalid query - The query was null or undefined' ) ;
@@ -22,6 +25,21 @@ function validateQuery(query, schema) {
22
25
if ( ! schema [ query . type ] ) {
23
26
throw new Error ( `Invalid query - The query type ${ query . type } was not defined on the schema` ) ;
24
27
}
28
+ if ( query . publisherId != null ) {
29
+ if (
30
+ typeof query . publisherId !== 'string' ||
31
+ query . publisherId . length > PUBLISHER_ID_MAX_LENGTH ||
32
+ query . publisherId . length < PUBLISHER_ID_MIN_LENGTH
33
+ ) {
34
+ throw new Error (
35
+ `Invalid query - The optional publisherId property must be a string between ${
36
+ PUBLISHER_ID_MIN_LENGTH
37
+ } and ${
38
+ PUBLISHER_ID_MAX_LENGTH
39
+ } characters in length`
40
+ ) ;
41
+ }
42
+ }
25
43
26
44
let fieldIsSet = ! ! query . field ;
27
45
let idIsSet = ! ! query . id ;
You can’t perform that action at this time.
0 commit comments