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