Skip to content

Commit

Permalink
fix validation messages when missing request body
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Jan 12, 2025
1 parent 3ccbccd commit c974abe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/plugins/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const zodValidationPlugin: FastifyPluginAsync = async (fastify, _options) => {
zodSchema: z.ZodTypeAny,
): Promise<void> {
try {
await zodSchema.parseAsync(request.body);
await zodSchema.parseAsync(request.body || {});
} catch (e: unknown) {
if (e instanceof ZodError) {
throw new ValidationError({
Expand Down

0 comments on commit c974abe

Please sign in to comment.