-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.js
More file actions
60 lines (46 loc) · 1.41 KB
/
validation.js
File metadata and controls
60 lines (46 loc) · 1.41 KB
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
54
55
56
57
58
59
60
const { body, validationResult } = require('express-validator');
const registerValidation = [
body('name').isLength({ min: 6 }),
body('email').isEmail(),
body('password').isLength({ min: 6 })
];
const loginValidation = [
body('email').isEmail(),
body('password').isLength({ min: 6 })
]
module.exports.registerValidation = registerValidation;
module.exports.loginValidation = loginValidation ;
/* const Joi = require('joi');
// Register validation
const registerValidation = (data) => {
const schema = Joi.object({
username: Joi.string()
.alphanum()
.min(3)
.max(30)
.required(),
password: Joi.string()
.pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
email: Joi.string()
.email()
});
console.log(schema.validate(data , schema));
return schema.validate(data , schema);
}
//login validation
const loginValidation = (data) => {
const schema = Joi.object({
username: Joi.string()
.alphanum()
.min(3)
.max(30)
.required(),
password: Joi.string()
.pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
email: Joi.string()
.email()
});
return schema.validate(data , schema);
}
module.exports.registerValidation = registerValidation;
module.exports.loginValidation = loginValidation ; */