-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
#220 got a bit off-track with scope creep. this PR takes a similar approach, but for internal use only - detects query parameters with array type schemas - adds an internal annotation to indicate these need preprocessing - applies a `z.preprocess` to coerce an individual value to an array of 1 element, before parsing with the array schema - for `joi` we resort to a pretty hacky wrapping of the schema with a object that does the preprocessing, as the `joi` extension API didn't work as I'd expected it to. will continue experimenting with making this a more generally useful feature for handling things like parsing `date-time` strings to be a `Date`, etc, separately. fixes #217 **Testing Notes** Need to improve automated test coverage still, but manually tested on a running server: - No query params - 1 element - 2 elements - 2 elements, 1 element and it seems to be working correctly. ``` listening on http://127.0.0.1:3000 query { query: {} } query { query: { statuses: [ 'complete' ] } } query { query: { statuses: [ 'complete', 'incomplete' ] } } query { query: { statuses: [ 'complete', 'incomplete' ] } } query { query: { statuses: [ 'complete', 'incomplete' ], tags: [ '123' ] } } ```
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.