-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalidation.js
More file actions
28 lines (25 loc) · 808 Bytes
/
validation.js
File metadata and controls
28 lines (25 loc) · 808 Bytes
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
const Joi = require('joi');
const profileSchema = Joi.object({
first_name: Joi.string().min(1).max(50).optional().messages({
'string.max': 'First name should have a maximum length of 50'
}),
last_name: Joi.string().min(1).max(50).optional().messages({
'string.max': 'Last name should have a maximum length of 50'
}),
email: Joi.string().email().optional().messages({
'string.email': 'Email must be a valid email address'
}),
profile_pic: Joi.string().uri().optional().messages({
'string.uri': 'Profile picture must be a valid URL'
})
});
const profileIdSchema = Joi.object({
id: Joi.number().integer().required().messages({
'number.base': 'ID must be an integer',
'any.required': 'ID is required'
})
});
module.exports = {
profileSchema,
profileIdSchema
};