-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.ts
More file actions
35 lines (31 loc) · 893 Bytes
/
Copy pathvalidation.ts
File metadata and controls
35 lines (31 loc) · 893 Bytes
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
import Joi from 'joi';
// VALIDATION
// Register Validation
const registerValidation = async ({ email, password, name }: any) => {
const schema = Joi.object().keys({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required(),
});
try {
await schema.validateAsync({ email, password, name });
} catch (error) {
return error;
}
return null;
};
// Login Validation
const loginValidation = async ({ email, password }: any) => {
const schema = Joi.object().keys({
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required(),
});
try {
await schema.validateAsync({ email, password });
} catch (error) {
return error;
}
return null;
};
module.exports.registerValidation = registerValidation;
module.exports.loginValidation = loginValidation;