66 lines
1.8 KiB
JavaScript
66 lines
1.8 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"
|
|
}),
|
|
plant_sub_section_description: Joi.string()
|
|
.max(200)
|
|
.allow('')
|
|
.optional()
|
|
.messages({
|
|
"string.base": "Description must be a string",
|
|
"string.max": "Description cannot exceed 200 characters"
|
|
}),
|
|
table_name_value: Joi.string()
|
|
.max(255)
|
|
.allow('')
|
|
.optional()
|
|
.messages({
|
|
"string.base": "Table name value must be a string",
|
|
"string.max": "Table name value cannot exceed 255 characters"
|
|
}),
|
|
is_active: Joi.boolean()
|
|
.default(true)
|
|
.optional()
|
|
});
|
|
|
|
const updateSubSectionSchema = Joi.object({
|
|
plant_sub_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(),
|
|
plant_sub_section_description: Joi.string()
|
|
.max(200)
|
|
.allow('')
|
|
.optional()
|
|
.messages({
|
|
"string.base": "Description must be a string",
|
|
"string.max": "Description cannot exceed 200 characters"
|
|
}),
|
|
table_name_value: Joi.string()
|
|
.max(255)
|
|
.allow('')
|
|
.optional()
|
|
.messages({
|
|
"string.base": "Table name value must be a string",
|
|
"string.max": "Table name value cannot exceed 255 characters"
|
|
}),
|
|
is_active: Joi.boolean().optional()
|
|
}).min(1);
|
|
|
|
module.exports = {
|
|
insertSubSectionSchema,
|
|
updateSubSectionSchema
|
|
};
|