-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.js
24 lines (21 loc) · 889 Bytes
/
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
// This is server side schema validation code
// Form validations for the client side is applied so that no wrong information is sent to the server.
// But users can use postman to send wrong information to the server. So we need to validate the data on the server side as well.
const Joi = require('joi');
module.exports.listingSchema = Joi.object({
listing:Joi.object({
title: Joi.string().required(),
description: Joi.string().required(),
location: Joi.string().required(),
country: Joi.string().required(),
price: Joi.number().required().min(1),
image: Joi.string().allow("", null),
category: Joi.string().required(),
}).required()
})
module.exports.reviewSchema = Joi.object({
review: Joi.object({
rating:Joi.number().required().min(1).max(5),
comment:Joi.string().required(),
}).required()
})