-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation.js
34 lines (27 loc) · 1.05 KB
/
validation.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
const Joi = require('@hapi/joi')
const postValidation = (data) => {
const schema = {
firstname: Joi.string().min(3).max(15).required(),
lastname: Joi.string().min(3).max(15).required(),
department: Joi.string().min(3).max(25).required(),
matric: Joi.string().min(12).max(12).required(),
time: Joi.string().required(),
level: Joi.string().required(),
gender: Joi.string().required(),
message: Joi.string().min(15).required(),
}
return Joi.validate(data, schema)
}
const complainValidation = (data) => {
const schema = {
firstname: Joi.string().min(3).max(15).required(),
lastname: Joi.string().min(3).max(15).required(),
department: Joi.string().min(3).max(25).required(),
matric: Joi.string().min(12).max(12).required(),
level: Joi.string().required(),
message: Joi.string().min(15).required(),
}
return Joi.validate(data, schema)
}
module.exports.postValidation = postValidation;
module.exports.complainValidation = complainValidation;