diff --git a/src/utils/internal/validate.ts b/src/utils/internal/validate.ts index 32e581a3..55cd0d73 100644 --- a/src/utils/internal/validate.ts +++ b/src/utils/internal/validate.ts @@ -38,7 +38,10 @@ export async function validateData( function createValidationError(validateError?: any) { throw createError({ status: 400, - message: validateError.message || "Validation Failed", - ...validateError, + statusMessage: "Bad Request", + message: validateError.message || "Bad Request", + data: { + ...validateError, + }, }); } diff --git a/test/validate.test.ts b/test/validate.test.ts index b7ae8f83..3040320e 100644 --- a/test/validate.test.ts +++ b/test/validate.test.ts @@ -92,6 +92,7 @@ describe("Validate", () => { it("Invalid", async () => { const res = await request.post("/zod").send({ invalid: true }); expect(res.status).toEqual(400); + expect(res.body.data?.issues?.[0]?.code).toEqual('invalid_type') }); }); });