-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Strict schema validation of methods fails #172
Comments
Thanks for reporting! Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that. |
Sure, I can set time aside to create a small reproducible example at some point this week 👍 |
I created a reproducible example here 👍: |
When you use fastify-sensible/lib/httpError.d.ts Lines 1 to 10 in 0244a15
This object is the data that is passed into the schema validation. As you can see in the above type definition, you would need to at least also test for z
.object({
status: z.literal(400),
statusCode: z.literal(400),
expose: z.boolean(),
error: z.literal("Bad Request"),
message: z.string(),
})
.strict() |
Prerequisites
Fastify version
4.28.1
Plugin version
5.6.0
Node.js version
20.17.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.7.6
Description
I noticed that when I add .strict() schema validation in my response schemas (zod), reply.*() breaks.
Eg. reply.unauthorized() returns this response:
This fails:
With this error:
This works:
Link to code that reproduces the bug
No response
Expected Behavior
Should be possible to add strict validation.
The text was updated successfully, but these errors were encountered: