add: CRUD schedule

This commit is contained in:
Muhammad Afif
2025-10-14 11:11:56 +07:00
parent 2c295ffd36
commit 3896f4103d
6 changed files with 224 additions and 32 deletions

View File

@@ -0,0 +1,28 @@
// ========================
// 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(),
});
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,
};