36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
const Joi = require('joi');
|
|
|
|
const createGroupSchema = Joi.object({
|
|
name: Joi.string().trim().min(1).max(100).required().messages({
|
|
'string.empty': 'Group name is required',
|
|
'string.min': 'Group name must be at least 1 character',
|
|
'string.max': 'Group name must not exceed 100 characters',
|
|
}),
|
|
members: Joi.array().items(Joi.number().integer().positive()).min(1).required().messages({
|
|
'array.min': 'At least one member is required',
|
|
'array.base': 'Members must be an array',
|
|
}),
|
|
description: Joi.string().trim().max(500).optional(),
|
|
isPrivate: Joi.boolean().optional(),
|
|
avatarUrl: Joi.string().uri().optional(),
|
|
});
|
|
|
|
const updateGroupSchema = Joi.object({
|
|
name: Joi.string().trim().min(1).max(100).optional(),
|
|
description: Joi.string().trim().max(500).optional(),
|
|
isPrivate: Joi.boolean().optional(),
|
|
avatarUrl: Joi.string().uri().optional(),
|
|
});
|
|
|
|
const addMembersSchema = Joi.object({
|
|
userIds: Joi.array().items(Joi.number().integer().positive()).min(1).required().messages({
|
|
'array.min': 'At least one user ID is required',
|
|
}),
|
|
});
|
|
|
|
module.exports = {
|
|
createGroupSchema,
|
|
updateGroupSchema,
|
|
addMembersSchema,
|
|
};
|