const Joi = require("joi");

const { Validate } = require("./Validate");
const { PropertyTypes } = require("../utils/Constants");

const AddEnquiryValidation = async (req, res, next) => {
  let propertyTypes = PropertyTypes.map((e) => e.id);
  const schema = Joi.object().keys({
    name: Joi.string().required().messages({
      "any:required": "Name field is required",
    }),
    email: Joi.string().required().messages({
      "any:required": "Email field is required",
    }),
    mobileNo: Joi.string().required().messages({
      "any:required": "Mobile No field is required",
    }),
    propertyType: Joi.string()
      .required()
      .valid(...propertyTypes)
      .messages({
        "any:required": "Property Type field is required",
      }),
    description: Joi.string().required().messages({
      "any:required": "Description field is required",
    }),
  });
  await Validate(req, res, next, schema);
};

module.exports = {
  AddEnquiryValidation,
};
