From 693a0980d9ed2d5178950311754099b2d5986dd2 Mon Sep 17 00:00:00 2001 From: leca Date: Mon, 4 Nov 2024 04:30:29 +0300 Subject: [PATCH] added tesf for NaN in existance.groupExists --- src/middlewares/existance.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/middlewares/existance.js b/src/middlewares/existance.js index 73c2c88..a796b98 100644 --- a/src/middlewares/existance.js +++ b/src/middlewares/existance.js @@ -3,7 +3,9 @@ import responseCodes from '../response/responseCodes.js'; import GroupService from '../services/group.js'; const groupExists = async (req, res, next) => { - let groupId = req.params.groupId || req.body.groupId; + let groupId = Number(req.params.groupId || req.body.groupId); + + if (isNaN(groupId)) throw new customError(`groupId is not a number`, responseCodes.responses.groups.id_not_found) let group = await GroupService.getById(groupId);