add: validate sub section
This commit is contained in:
31
validate/sub_section.schema.js
Normal file
31
validate/sub_section.schema.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const Joi = require("joi");
|
||||
|
||||
// ========================
|
||||
// Plant Sub Section Validation
|
||||
// ========================
|
||||
const insertSubSectionSchema = Joi.object({
|
||||
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"
|
||||
}),
|
||||
});
|
||||
|
||||
const updateSubSectionSchema = Joi.object({
|
||||
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",
|
||||
}),
|
||||
}).min(1).messages({
|
||||
"object.min": "At least one field must be provided to update",
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
insertSubSectionSchema,
|
||||
updateSubSectionSchema
|
||||
};
|
||||
Reference in New Issue
Block a user