Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Make the query values more strict (#698)
- Loading branch information
1 parent
bf86d58
commit 5376216
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
const is = require('@sindresorhus/is'); | ||
|
||
module.exports = query => { | ||
const verify = (value, type) => { | ||
if (!is.string(value) && !is.number(value) && !is.boolean(value) && !is.null(value)) { | ||
throw new TypeError(`The query ${type} '${value}' must be a string, number, boolean or null`); | ||
} | ||
}; | ||
|
||
for (const [key, value] of Object.entries(query)) { | ||
verify(key, 'key'); | ||
verify(value, 'value'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters