forked from GDGVIT/WomenTechies20-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation.js
53 lines (52 loc) · 1.21 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//jshint esversion:6
//VALIDATION
const Joi = require("@hapi/joi");
//REGISTER VALIDATION
const registerValidation = data => {
const schema = Joi.object({
name: Joi.string().required(),
email: Joi.string()
.min(6)
.required()
.email(),
regNo: Joi.string()
.min(9)
.required(),
gender: Joi.string()
.min(4)
.required(),
password: Joi.string()
.min(6)
.required()
});
return schema.validate(data);
};
const loginValidation = data => {
const schema = Joi.object({
email: Joi.string()
.min(6)
.required()
.email(),
password: Joi.string()
.min(6)
.required()
});
return schema.validate(data);
};
const sponsorValidation = data => {
const schema = Joi.object({
name: Joi.string().required(),
company: Joi.string().required(),
email: Joi.string()
.min(6)
.required()
.email(),
phone: Joi.number()
.required()
.min(10)
});
return schema.validate(data);
};
module.exports.registerValidation = registerValidation;
module.exports.loginValidation = loginValidation;
module.exports.sponsorValidation = sponsorValidation;