export function validateLogData(data) { const errors = []; // Check if data exists if (!data || typeof data !== 'object') { errors.push('Request body must be a valid JSON object'); return { isValid: false, errors }; } // Validate required message field if (!data.body || typeof data.body !== 'string') { errors.push('body field is required and must be a string'); } else if (data.body.trim().length === 0) { errors.push('body field cannot be empty'); } // Validate optional fields if provided if (data.project !== undefined && typeof data.project !== 'string') { errors.push('project field must be a string if provided'); } if (data.type !== undefined && typeof data.type !== 'string') { errors.push('type field must be a string if provided'); } if (data.owner !== undefined && typeof data.owner !== 'string') { errors.push('owner field must be a string if provided'); } if (data.avatar_src !== undefined && typeof data.avatar_src !== 'string') { errors.push('avatar_src field must be a string if provided'); } return { isValid: errors.length === 0, errors }; }