-
Notifications
You must be signed in to change notification settings - Fork 218
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
feat: request validation using handler object syntax validate
and validateEvent(event)
#496
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #496 +/- ##
==========================================
+ Coverage 77.83% 83.19% +5.36%
==========================================
Files 47 32 -15
Lines 4286 3654 -632
Branches 611 545 -66
==========================================
- Hits 3336 3040 -296
+ Misses 933 614 -319
+ Partials 17 0 -17 β View full report in Codecov by Sentry. |
I am wondering if we can alternatively support |
The issue is the typing. It might be possible but will be a lot more complex, to create chainable validators. (So output of one becomes input of another.) |
It makes sense for type complexity I am thinking it could give some overhead for when we want to do body normalization, we actually read the body (and an external library can apply schema normalization). Only returning a boolean + typed Event will cause to loose this information (unless the utils support a context caching mechanism for when we later call Also, it would be nice if we expose a generic utility |
validate
and validateEvent(event)
validate
and validateEvent(event)
validate
and validateEvent(event)
Hi, I wish to understand how this change would interact with, or eliminates the need for, the validation options via community packages mentioned in h3's README? https://github.com/unjs/h3#community-packages |
β¦to util cached values
Update: Both me and @danielroe need to rethink about whole typing and validation and how it works with downstream (Nitro and Nuxt) types and best type/runtime safely+perf balance which is tricky at the moment. Making it draft until after 1.8 to iterate. |
Deploying unjs-h3 with Β Β Cloudflare Pages
|
π Linked issue
β Type of change
π Description
This allows inferring type of event by passing a validate function which needs to return the event (as validated). It's simple and allows any kind of validation, throwing an error if invalid input is provided.
π Checklist