-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.js
45 lines (39 loc) · 1 KB
/
schema.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
const Joi = require("joi");
const userValidationSchema = Joi.object({
email: Joi.string().required().email(),
password: Joi.string().required().min(6),
avatar: Joi.string(),
});
const schemaPost = Joi.object({
name: Joi.string().required().min(3).max(30),
email: Joi.string()
.email({
minDomainSegments: 2,
tlds: { allow: ["com", "net", "pl", "org", "eu"] },
})
.required(),
phone: Joi.string().required().min(5),
favorite: Joi.boolean(),
});
const schemaPut = Joi.object({
name: Joi.string().min(3).max(30),
email: Joi.string().email({
minDomainSegments: 2,
tlds: { allow: ["com", "net", "pl", "org", "eu"] },
}),
phone: Joi.string().min(5),
favorite: Joi.boolean(),
});
const schemaPatch = Joi.object({
favorite: Joi.boolean().required(),
});
const schemaSecondEmailVerification = Joi.object({
email: Joi.string().required().email(),
});
module.exports = {
userValidationSchema,
schemaPost,
schemaPut,
schemaPatch,
schemaSecondEmailVerification,
};