-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation.js
43 lines (38 loc) · 889 Bytes
/
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
// Validation ...
const Joi = require('@hapi/joi');
/**
* Validate register schema
*/
const validateRegister = (data) => {
const schema = Joi.object ({
usrName: Joi.string()
.min(4)
.required(),
email: Joi.string()
.min(6)
.required()
.email(),
password: Joi.string()
.min(6)
.required()
});
return schema.validate(data, schema);
};
/**
* Validate login schema
*/
const validateLogin = (data) => {
const schema = Joi.object({
email: Joi.string()
.min(6)
.required()
.email(),
password: Joi.string()
.min(6)
.required()
});
return schema.validate(data, schema);
};
// Exports
module.exports.validateLogin = validateLogin;
module.exports.validateRegister = validateRegister;