-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.js
More file actions
26 lines (24 loc) · 947 Bytes
/
schema.js
File metadata and controls
26 lines (24 loc) · 947 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
const joi = require("joi");
const Listings = require("./models/listing");
//this is a schema for server side validaton
module.exports.listingSchema = joi.object({
//whenever we get req listing obj should present at all
listing: joi.object({
title : joi.string().required(),
description : joi.string().required(),
country : joi.string().required(),
location : joi.string().required(),
price : joi.number().required().min(0),
image: {
url: joi.string().allow("", null),
},
category: joi.string().valid("Trending", "Rooms", "Iconic Cities", "Mountain", "Castles", "Amazing Pools", "Camping", "Farms", "Arctic", "Domes", "Boats")
.required()
}).required()
});
module.exports.reviewSchema = joi.object({
review: joi.object({
rating: joi.number().required().min(1).max(5),
comment: joi.string().required()
}).required()
});