diff --git a/src/controllers/product/type-controller.ts b/src/controllers/product/type-controller.ts index 2395b96..ef859da 100644 --- a/src/controllers/product/type-controller.ts +++ b/src/controllers/product/type-controller.ts @@ -114,6 +114,17 @@ export class ProductType extends Controller { @Body() body: ProductTypeUpdate, @Path() typeId: string, ) { + if ( + body.productGroupId && + !(await prisma.productType.findFirst({ where: { id: body.productGroupId } })) + ) { + throw new HttpError( + HttpStatus.BAD_REQUEST, + "Product group cannot be found.", + "missing_or_invalid_parameter", + ); + } + if (!(await prisma.productType.findUnique({ where: { id: typeId } }))) { throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "data_not_found"); }