crud: notification
This commit is contained in:
65
validate/notification.schema.js
Normal file
65
validate/notification.schema.js
Normal file
@@ -0,0 +1,65 @@
|
||||
// ========================
|
||||
// Notification Validation
|
||||
// ========================
|
||||
|
||||
const Joi = require("joi");
|
||||
|
||||
// ========================
|
||||
// Insert Notification Schema
|
||||
// ========================
|
||||
const insertNotificationSchema = Joi.object({
|
||||
error_code_id: Joi.number().required().messages({
|
||||
"any.required": "error_code_id is required",
|
||||
"number.base": "error_code_id must be a number",
|
||||
}),
|
||||
|
||||
is_send: Joi.boolean().required().messages({
|
||||
"any.required": "is_send is required",
|
||||
"boolean.base": "is_send must be a boolean",
|
||||
}),
|
||||
|
||||
is_delivered: Joi.boolean().required().messages({
|
||||
"any.required": "is_delivered is required",
|
||||
"boolean.base": "is_delivered must be a boolean",
|
||||
}),
|
||||
|
||||
is_read: Joi.boolean().required().messages({
|
||||
"any.required": "is_read is required",
|
||||
"boolean.base": "is_read must be a boolean",
|
||||
}),
|
||||
|
||||
is_active: Joi.boolean().required().messages({
|
||||
"any.required": "is_active is required",
|
||||
"boolean.base": "is_active must be a boolean",
|
||||
}),
|
||||
});
|
||||
|
||||
// ========================
|
||||
// Update Notification Schema
|
||||
// ========================
|
||||
const updateNotificationSchema = Joi.object({
|
||||
error_code_id: Joi.number().optional().messages({
|
||||
"number.base": "error_code_id must be a number",
|
||||
}),
|
||||
|
||||
is_send: Joi.boolean().optional().messages({
|
||||
"boolean.base": "is_send must be a boolean",
|
||||
}),
|
||||
|
||||
is_delivered: Joi.boolean().optional().messages({
|
||||
"boolean.base": "is_delivered must be a boolean",
|
||||
}),
|
||||
|
||||
is_read: Joi.boolean().optional().messages({
|
||||
"boolean.base": "is_read must be a boolean",
|
||||
}),
|
||||
|
||||
is_active: Joi.boolean().optional().messages({
|
||||
"boolean.base": "is_active must be a boolean",
|
||||
}),
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
insertNotificationSchema,
|
||||
updateNotificationSchema,
|
||||
};
|
||||
Reference in New Issue
Block a user