check for group name

This commit is contained in:
2024-10-31 10:06:49 +03:00
parent d809abd17b
commit 6adb48aeab
2 changed files with 12 additions and 2 deletions

View File

@@ -11,6 +11,15 @@ const groupExists = async (req, res, next) => {
next();
};
const groupNameExists = async (req, res, next) => {
let groupName = req.params.groupName || req.body.groupName;
let group = await GroupService.getByName(groupName);
if (!group) throw new customError(`group does not exists`, responseCodes.responses.groups.name_not_found);
next();
};
const localIdExists = async (req, res, next) => {
let localId = req.params.localId || req.body.localId;
@@ -18,4 +27,5 @@ const localIdExists = async (req, res, next) => {
next();
}
export default { groupExists, localIdExists }
export default { groupExists, localIdExists, groupNameExists }