-
Notifications
You must be signed in to change notification settings - Fork 297
feat: customizable validation errors #1146
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
base: main
Are you sure you want to change the base?
Conversation
|
Oh, is it normal that we have a |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Deploying h3dev with
|
| Latest commit: |
9f96225
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://69c3837d.h3dev.pages.dev |
| Branch Preview URL: | https://feat-custom-validation-error.h3dev.pages.dev |
|
@pi0 any update on this? |
|
Hi dear @sandros94. It is in my todo list, in meantime do you have time to help on fixing merge conflicts and adressing #1146 (comment) 🙏🏼 |
Yes absolutely! And sorry, I completely forgot about that review 😅 |
|
I'm terribly sorry, I didn't realize that in 1e4d720 I did not update the docs 🙈 For now I would leave it as only Let me know if there is anything else I should take care of |
|
@sandros94 updated implementation to be more compact API. Love your opinion on latest changes. |
Thank you, and yes it required a bit of cleanup |
resolves #982
I've added an additional argument to each
readValidatedBody,getValidatedQueryandgetValidatedRouteParamswhich can be either an error object or a function that returns one. If a standard-schema is being used, then theissuesarray is available as an argument for the function variant.This allows for the following custom error, which will ouput a markdown list of all the errors recorded:
I've also updated the
defineValidatedHandler, which brings three more properties:bodyErrors,headersErrorsandqueryErrors. All allowing for either error object or function that returns oneAdded two types, but I'm not super satisfied with
ValidateIssuesnaming (I'm open for suggestions):I've also made sure that if a
new HTTPErroris thrown during validation, its content will be directly passed as is, quite useful for non-standard-schema validations.