-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix #26 Validation Error Response #28
Conversation
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.
lgtm
I think we should return those types from Fastify
@mcollina Hi, is it possible to have this PR merged through or are there some upstream considerations around potentially exporting the |
nothing, this could land and ship. Exporting the other things would be a bonus. I'm on vacation until Monday and I'm falling behind on releases. |
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.
lgtm
Can you rebase? There is a conflict. |
@mcollina upstream changes have been merged. |
Checklist
npm run test
andnpm run benchmark
and the Code of conduct
This PR updates the
TypeBoxValidatorCompiler
to return values ofFastifySchemaValidationError
on validation fail. This to prevent Fastify from crashing due to throwing an exception within the compiler validate callback. As of this PR, invalid data passed to the route will now result in a correct400: Bad Request
and an appropriate error object is returned on the response with a message hinting at what data is incorrect.Note
I note that Fastify currently doesn't appear to directly export the
FastifyValidationResult
andFastifySchemaValidationError
types. These types are accessible by importingfastify/types/schema
however. I have left a comment here to potentially update the implementation with a TS assertion on the error result (for correctness), however the current error result seems to generate adequate errors with the properties specified.Submitting for community review