forked from SHaKTiMaan1/care-webapp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
validation.js
40 lines (35 loc) · 1.3 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
const Joi = require("@hapi/joi");
//REGISTER VALIDATION
const registerValidationEmployee = (validationData) => {
const schema = Joi.object({
employee_id: Joi.string().min(2),
name: Joi.string().min(2).required(),
contactNumber: Joi.number().min(1111111111).max(9999999999),
email: Joi.string().min(7).required().email(),
cci_id: Joi.string().min(4).max(30).required(),
password: Joi.string().min(4).max(1024).required(),
});
return schema.validate(validationData);
};
//LOGIN VALIDATION
const loginValidation = (validationData) => {
const schema = Joi.object({
email: Joi.string().min(7).required().email(),
password: Joi.string().min(4).required(),
});
return schema.validate(validationData);
};
//CHILD REGISTRATION VALIDATION
const childRegistrationValidation = (validationData) => {
const schema = Joi.object({
name: Joi.string().min(3).required(),
age: Joi.number().integer().required(),
cci_name: Joi.string().min(3).max(120).required(),
cci_id: Joi.string().min(4).max(30).required(),
address: Joi.string(),
});
return schema.validate(validationData);
};
module.exports.registerValidationEmployee = registerValidationEmployee;
module.exports.loginValidation = loginValidation;
module.exports.childRegistrationValidation = childRegistrationValidation;