import sanitizeHtml from 'sanitize-html' const allowedTags = ['em', 'span'] const allowedAttributes = { span: ['style'], } export function sanitizeValue(value: unknown): unknown { if (typeof value === 'string') { return sanitizeHtml(value, { allowedTags, allowedAttributes }) } if (Array.isArray(value)) { return value.map(sanitizeValue) } if (value && typeof value === 'object') { const result: Record = {} for (const [key, val] of Object.entries(value)) { result[key] = sanitizeValue(val) } return result } return value }