-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.js
More file actions
42 lines (36 loc) · 1.15 KB
/
schema.js
File metadata and controls
42 lines (36 loc) · 1.15 KB
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
const Joi = require('joi');
const listingSchema = Joi.object({
listing: Joi.object({
title: Joi.string().required(),
description: Joi.string().required(),
image: Joi.object({
filename: Joi.string().allow(""), // Allow empty filename
url: Joi.string().uri().allow("") // Allow empty URL (for file uploads)
}).allow(null), // Allow null image
price: Joi.number().required().min(0),
location: Joi.string().required(),
country: Joi.string().required(),
category: Joi.string().valid(
"hotel",
"city",
"mountain",
"historical",
"beach",
"lakeside",
"forest",
"luxury",
"igloo",
"exotic",
"skiing",
"tropical",
"rainforest"
).required() // Ensure category is one of the valid values
}).required()
});
const reviewSchema = Joi.object({
review: Joi.object({
rating:Joi.number().required(),
comment:Joi.string().required(),
}).required()
});
module.exports={listingSchema,reviewSchema};