-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverifyTicketReqBody.js
36 lines (28 loc) · 940 Bytes
/
verifyTicketReqBody.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const constants = require('../utils/constants')
const validateTicketReqBody = async(req,res, next)=>{
const title = req.body.title
const description = req.body.description
if(!title || !description){
res.status(400).send({
message : "Failed ! Details are not provided"
})
return
}
next()
}
const validateTicketStatus = async(req, res, next) => {
const status = req.body.status;
const statusTypes = [
constants.ticketStatus.open,
constants.ticketStatus.inprogress,
constants.ticketStatus.blocked,
constants.ticketStatus.closed
]
if(status && !statusTypes.includes(status)) {
res.status(400).send({
message: "status provided is invalid. Possible values CLOSED | BLOCKED | IN_PROGRESS | OPEN"
})
}
next();
}
module.exports = {validateTicketReqBody, validateTicketReqBody, validateTicketStatus}