-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschemas.js
32 lines (29 loc) · 914 Bytes
/
schemas.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
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.legendSchema = Joi.object({
name:Joi.string().required().min(4).max(30).escapeHTML(),
DOB: Joi.date().required(),
POB:Joi.string().required().escapeHTML(),
about:Joi.string().required(),
deleteImages:Joi.array(),
});