Files
cod-api/validate/sub_section.schema.js
2025-10-24 10:31:27 +07:00

36 lines
1.0 KiB
JavaScript

const Joi = require("joi");
// ========================
// Plant Sub Section Validation
// ========================
const insertSubSectionSchema = Joi.object({
plant_sub_section_name: Joi.string()
.max(200)
.required()
.messages({
"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(),
value: Joi.string().max(100).optional()
});
const updateSubSectionSchema = Joi.object({
plant_sub_section_namesub_section_name: Joi.string()
.max(200)
.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(),
value: Joi.string().max(100).optional()
}).min(1).messages({
"object.min": "At least one field must be provided to update",
});
module.exports = {
insertSubSectionSchema,
updateSubSectionSchema
};