-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation.js
39 lines (35 loc) · 1.19 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
35
36
37
38
39
const Joi = require("@hapi/joi");
const registerValidation = data => {
const schema = Joi.object({
name: Joi.string().required().max(100),
email: Joi.string().email().required(),
phone: Joi.string().required().max(10).min(10),
password: Joi.string().required().min(8)
});
return schema.validate(data);
};
const loginValidation = data => {
const schema = Joi.object({
email: Joi.string().email().required(),
password: Joi.string().required().min(8)
});
return schema.validate(data);
};
const updateValidation = data => {
const schema = Joi.object({
name: Joi.string().required().max(100),
email: Joi.string().email().required(),
phone: Joi.string().required().max(10).min(10)
});
return schema.validate(data);
};
const changePasswordValidation = data =>{
const schema = Joi.object({
password: Joi.string().required().min(8)
});
return schema.validate(data);
};
module.exports.registerValidation = registerValidation;
module.exports.loginValidation = loginValidation;
module.exports.updateValidation = updateValidation;
module.exports.changePasswordValidation = changePasswordValidation;