-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.js
35 lines (28 loc) · 1.05 KB
/
validate.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
const Joi = require("joi")
module.exports = {
registerValidate: (data) => {
const registerValidateSchema = Joi.object({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required()
})
return registerValidateSchema.validate(data);
},
loginValidate: (data) => {
const loginValidateSchema = Joi.object({
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required()
})
return loginValidateSchema.validate(data);
},
newFriendValidate: (data) => {
const newFriendValidateSchema = Joi.object({
name: Joi.string().max(255).required(),
location: Joi.string().max(30).required(),
phoneNumber: Joi.string().max(13).min(10).required(),
aboutFriend: Joi.string().min(30).required(),
status: Joi.string().max(50).required()
})
return newFriendValidateSchema.validate(data);
}
}