add: validate is_active
This commit is contained in:
@@ -8,12 +8,14 @@ const insertRolesSchema = Joi.object({
|
||||
role_name: Joi.string().max(100).required(),
|
||||
role_level: Joi.number().required(),
|
||||
role_description: Joi.string().max(100).required(),
|
||||
is_active: Joi.boolean().required(),
|
||||
});
|
||||
|
||||
const updateRolesSchema = Joi.object({
|
||||
role_name: Joi.string().max(100),
|
||||
role_level: Joi.number(),
|
||||
role_description: Joi.string().max(100),
|
||||
role_name: Joi.string().max(100).optional(),
|
||||
role_level: Joi.number().optional(),
|
||||
role_description: Joi.string().max(100).optional(),
|
||||
is_active: Joi.boolean().optional()
|
||||
}).min(1);
|
||||
|
||||
|
||||
|
||||
@@ -24,18 +24,19 @@ const insertShiftSchema = Joi.object({
|
||||
});
|
||||
|
||||
const updateShiftSchema = Joi.object({
|
||||
shift_name: Joi.string().max(100),
|
||||
is_active:Joi.boolean(),
|
||||
shift_name: Joi.string().max(100).optional(),
|
||||
is_active:Joi.boolean().optional(),
|
||||
start_time: Joi.string()
|
||||
.pattern(timePattern)
|
||||
.messages({
|
||||
"string.pattern.base": "start_time harus dalam format HH:mm atau HH:mm:ss",
|
||||
}),
|
||||
}).optional(),
|
||||
end_time: Joi.string()
|
||||
.pattern(timePattern)
|
||||
.messages({
|
||||
"string.pattern.base": "end_time harus dalam format HH:mm atau HH:mm:ss",
|
||||
}),
|
||||
is_active: Joi.boolean().optional()
|
||||
}).min(1);
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -7,14 +7,16 @@ const insertStatusSchema = Joi.object({
|
||||
status_number: Joi.number().integer().required(),
|
||||
status_name: Joi.string().max(200).required(),
|
||||
status_color: Joi.string().max(200).required(),
|
||||
status_description: Joi.string().allow('', null)
|
||||
status_description: Joi.string().allow('', null),
|
||||
is_active: Joi.boolean().required(),
|
||||
});
|
||||
|
||||
const updateStatusSchema = Joi.object({
|
||||
status_number: Joi.number().integer(),
|
||||
status_name: Joi.string().max(200),
|
||||
status_color: Joi.string().max(200),
|
||||
status_description: Joi.string().allow('', null)
|
||||
status_number: Joi.number().integer().optional(),
|
||||
status_name: Joi.string().max(200).optional(),
|
||||
status_color: Joi.string().max(200).optional(),
|
||||
status_description: Joi.string().allow('', null).optional(),
|
||||
is_active: Joi.boolean().optional()
|
||||
}).min(1);
|
||||
|
||||
// ✅ Export dengan CommonJS
|
||||
|
||||
@@ -11,7 +11,8 @@ const insertSubSectionSchema = Joi.object({
|
||||
"string.base": "Sub section name must be a string",
|
||||
"string.max": "Sub section name cannot exceed 200 characters",
|
||||
"any.required": "Sub section name is required"
|
||||
}),
|
||||
}).required(),
|
||||
is_active: Joi.boolean().required(),
|
||||
});
|
||||
|
||||
const updateSubSectionSchema = Joi.object({
|
||||
@@ -20,7 +21,8 @@ const updateSubSectionSchema = Joi.object({
|
||||
.messages({
|
||||
"string.base": "Sub section name must be a string",
|
||||
"string.max": "Sub section name cannot exceed 200 characters",
|
||||
}),
|
||||
}).optional(),
|
||||
is_active: Joi.boolean().optional(),
|
||||
}).min(1).messages({
|
||||
"object.min": "At least one field must be provided to update",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user