// ========================
// Schedule Validation

const Joi = require("joi");

const datePattern = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;

const insertScheduleSchema = Joi.object({
  schedule_date: Joi.string().pattern(datePattern).required().messages({
    "string.pattern.base": "schedule_date harus dalam format YYYY-MM-DD",
    "any.required": "schedule_date wajib diisi",
  }),
  is_active: Joi.boolean().required(),
  shift_id: Joi.number(),
  next_day: Joi.number().required(),
});

const updateScheduleSchema = Joi.object({
  schedule_date: Joi.string().pattern(datePattern).messages({
    "string.pattern.base": "schedule_date harus dalam format YYYY-MM-DD",
  }),
  is_active: Joi.boolean(),
  shift_id: Joi.number(),
}).min(1);

module.exports = {
  insertScheduleSchema,
  updateScheduleSchema,
};
