feat: improve validations

This commit is contained in:
Agusti Fernandez Pardo committed 2022-03-27 15:15:46 +02:00
1 parent c561b16f85
commit 0e3131d866
6 files changed
+15 -59

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ export async function attendee(req: NextApiRequest, res: NextApiResponse<Respons
// This catches the error thrown by prisma.attendee.delete() if the resource is not found.
else res.status(400).json({ message: `Resource with id:${safe.data.id} was not found`});
// Reject any other HTTP method than POST
} else res.status(405).json({ message: "Only DELETE Method allowed in /availabilities/[id]/delete endpoint" });
} else res.status(405).json({ message: "Only DELETE Method allowed" });
}
export default withValidQueryIdTransformParseInt(attendee);
+2 -3
View File
@@ -1,7 +1,6 @@
import prisma from "@calcom/prisma";
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt, withValidQueryIdTransformParseInt } from "@lib/validations/shared/queryIdTransformParseInt";
@@ -21,7 +20,7 @@ export async function availability(req: NextApiRequest, res: NextApiResponse<Res
// This catches the error thrown by prisma.availability.delete() if the resource is not found.
else res.status(400).json({ message: `Resource with id:${safe.data.id} was not found`});
// Reject any other HTTP method than POST
} else res.status(405).json({ message: "Only DELETE Method allowed in /availabilities/[id]/delete endpoint" });
} else res.status(405).json({ message: "Only DELETE Method allowed" });
}
export default withValidQueryIdTransformParseInt(availability);