-
Notifications
You must be signed in to change notification settings - Fork 179
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 Report
@@ Coverage Diff @@
## main #496 +/- ##
==========================================
+ Coverage 82.41% 83.19% +0.77%
==========================================
Files 31 32 +1
Lines 3549 3654 +105
Branches 529 545 +16
==========================================
+ Hits 2925 3040 +115
+ Misses 624 614 -10
|
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. |
π 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