Skip to content

Commit

Permalink
Merge pull request #441 from tcet-opensource/425-add-validation-for-g…
Browse files Browse the repository at this point in the history
…roup

[Added]validation for group
  • Loading branch information
TejasNair9977 authored Nov 8, 2023
2 parents 22235ee + b5767ec commit aabfee3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controller/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ import {
updateGroupById,
} from "#services/group";
import { logger } from "#util";
import { isEntityIdValid } from "#middleware/entityIdValidation";
import Student from '#models/student';

async function addGroup(req, res) {
const { title, student } = req.body;
const isStudentValid = await isEntityIdValid(student, Student);
try {
if(isStudentValid){
const group = await createGroup(title, student);
res.json({ res: `added group ${group.id}`, id: group.id });
}
else{
res.status(400).json({err: "Invalid Id"});
}
} catch (error) {
logger.error("Error while inserting", error);
res.status(500);
Expand Down

0 comments on commit aabfee3

Please sign in to comment.