-
Notifications
You must be signed in to change notification settings - Fork 0
/
schmeas.js
60 lines (53 loc) · 1.86 KB
/
schmeas.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const BaseJoi = require('joi');
const sanitizeHtml = require('sanitize-html');
const extension = (joi) => ({
type: 'string',
base: joi.string(),
messages: {
'string.escapeHTML': '{{#label}} must not include HTML!'
},
rules: {
escapeHTML: {
validate(value, helpers) {
const clean = sanitizeHtml(value, {
allowedTags: [],
allowedAttributes: {},
});
if (clean !== value) return helpers.error('string.escapeHTML', { value })
return clean;
}
}
}
});
const Joi = BaseJoi.extend(extension);
module.exports.userSchema = Joi.object({
user: Joi.object({
name: Joi.string().required(),
branch: Joi.string().required().escapeHTML(),
rollno: Joi.number().integer().required(),
cgpa: Joi.number().required().min(1).max(10),
// image:Joi.string().required(),
description: Joi.string().required().escapeHTML(),
state: Joi.string().required().escapeHTML(),
club: Joi.string().required().escapeHTML(),
semester: Joi.number().required().min(1).max(8).integer(),
}).required(),
deleteImages: Joi.array()
});
module.exports.facultySchema = Joi.object({
faculty: Joi.object({
name: Joi.string().required().escapeHTML(),
department: Joi.string().required().escapeHTML(),
designation: Joi.string().required().escapeHTML(),
experience: Joi.number().min(0).required(),
qualifications: Joi.string().required().escapeHTML(),
// image: Joi.string().required()
}).required(),
deleteImages: Joi.array()
});
module.exports.remarkSchema = Joi.object({
remark: Joi.object({
body: Joi.string().required().escapeHTML(),
performance: Joi.number().required().min(1).max(5),
}).required()
});