-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation.js
46 lines (42 loc) · 1.14 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
41
42
43
44
45
46
const Joi = require('@hapi/joi')
/**
* Register User Validation
* @param {name, email, password} data
*/
const registerValidation = (data) => {
const schema = Joi.object({
name: Joi.string().required(),
email: Joi.string().required().email(),
password: Joi.string().required().min(6)
})
return schema.validate(data)
}
/**
* Login User Validation
* @param {email, password} data
*/
const loginValidation = (data) => {
const schema = Joi.object({
email: Joi.string().required().email(),
password: Joi.string().required().min(6)
})
return schema.validate(data)
}
/**
* Add event validation
* @param {title, date, description, organizer} data
*/
const addEventValidation = (data) => {
const schema = Joi.object({
title: Joi.string().required(),
date: Joi.date().required(),
place: Joi.string().required(),
description: Joi.string().required(),
quota: Joi.number().required(),
organizer: Joi.required()
})
return schema.validate(data)
}
module.exports.registerValidation = registerValidation
module.exports.loginValidation = loginValidation
module.exports.addEventValidation = addEventValidation