-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom validators in ApiHandler
#21
Conversation
Codecov Report
@@ Coverage Diff @@
## main #21 +/- ##
==========================================
+ Coverage 83.22% 83.72% +0.49%
==========================================
Files 11 11
Lines 322 338 +16
Branches 76 78 +2
==========================================
+ Hits 268 283 +15
- Misses 50 55 +5
+ Partials 4 0 -4
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
Unit Test Results 1 files ±0 4 suites ±0 5s ⏱️ ±0s Results for commit c791e8b. ± Comparison against base commit b68b2f6. This pull request removes 3 and adds 5 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
if (validators) { | ||
validateBodyResult = validateInput(validators.body, event.body); | ||
validateQueryResult = validateInput(validators.query, queryBody); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention here is to give validators
top priority if both validation methods are specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! One comment on the argument type of the validate function
body?: JSONSchemaType<B>; | ||
query?: JSONSchemaType<Q>; | ||
response?: JSONSchemaType<R>; | ||
}; | ||
|
||
validators?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice--thanks for making this optional. We have a few routes that don't require schemas--and passing in an empty object felt werid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFG!
ajv
andschemas
options inside ofApiHandler
validators
to be passed in as an alternative toschemas
AJV
logic to be wiped in next major release.@faceteer/facet
repo)