-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.js
More file actions
38 lines (35 loc) · 833 Bytes
/
schema.js
File metadata and controls
38 lines (35 loc) · 833 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
27
28
29
30
31
32
33
34
35
36
37
38
const joi = require("joi");
// Listing Schema
const 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(1000),
image: joi.string().allow("", null),
category: joi
.string()
.valid(
"mountains",
"artic",
"Swimming",
"Iconic",
"farms",
"castle",
"camping",
"vineyard"
)
.required(),
}),
});
//Review Schema
const reviewSchema = joi.object({
review: joi
.object({
rating: joi.number().required().min(1).max(5),
comment: joi.string().required(),
})
.required(),
});
module.exports = { listingSchema, reviewSchema };