From ace419fa3eed21cb127b17d91f6e55db2d500f88 Mon Sep 17 00:00:00 2001 From: Antony Kurniawan Date: Sat, 11 Oct 2025 16:20:54 +0700 Subject: [PATCH] add: validate sub section --- validate/sub_section.schema.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 validate/sub_section.schema.js diff --git a/validate/sub_section.schema.js b/validate/sub_section.schema.js new file mode 100644 index 0000000..616ac90 --- /dev/null +++ b/validate/sub_section.schema.js @@ -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 +};