add: crud contact
This commit is contained in:
35
validate/contact.schema.js
Normal file
35
validate/contact.schema.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const Joi = require("joi");
|
||||
|
||||
// ========================
|
||||
// Contacts Validation
|
||||
// ========================
|
||||
const insertContactSchema = Joi.object({
|
||||
contact_name: Joi.string().min(3).max(100).required(),
|
||||
contact_phone: Joi.string()
|
||||
.pattern(/^(?:\+62|0)8\d{7,10}$/)
|
||||
.required()
|
||||
.messages({
|
||||
"string.pattern.base":
|
||||
"Phone number must be a valid Indonesian number in format +628XXXXXXXXX",
|
||||
}),
|
||||
is_active: Joi.boolean().required(),
|
||||
contact_type: Joi.string().max(255).required()
|
||||
});
|
||||
|
||||
const updateContactSchema = Joi.object({
|
||||
contact_name: Joi.string().min(3).max(100).required(),
|
||||
contact_phone: Joi.string()
|
||||
.pattern(/^(?:\+62|0)8\d{7,10}$/)
|
||||
.required()
|
||||
.messages({
|
||||
"string.pattern.base":
|
||||
"Phone number must be a valid Indonesian number in format +628XXXXXXXXX",
|
||||
}),
|
||||
is_active: Joi.boolean().optional(),
|
||||
contact_type: Joi.string().max(255).optional()
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
insertContactSchema,
|
||||
updateContactSchema,
|
||||
};
|
||||
Reference in New Issue
Block a user