UNPKG

igniteui-theming

Version:

A set of Sass variables, mixins, and functions for generating palettes, typography, and elevations used by Ignite UI components.

46 lines (45 loc) 1.69 kB
//#region src/utils/result.ts /** * Format validation errors and warnings for display. * * @param result - Validation result to format * @param options - Formatting options * @returns Formatted markdown string */ function formatValidationMessages(result, options = {}) { const { includeIcons = true, includeSuggestions = true, includeTips = true } = options; const lines = []; if (result.errors.length > 0) { lines.push("**Errors:**"); for (const error of result.errors) { const icon = includeIcons ? "❌ " : ""; const prefix = error.field ? `\`${error.field}\`: ` : ""; lines.push(`- ${icon}${prefix}${error.message}`); if (includeSuggestions && error.suggestion) lines.push(` Suggestion: ${error.suggestion}`); } } if (result.warnings.length > 0) { if (lines.length > 0) lines.push(""); lines.push("**Warnings:**"); for (const warning of result.warnings) { const icon = includeIcons ? warning.severity === "info" ? "ℹ️ " : "⚠️ " : ""; const prefix = warning.field ? `\`${warning.field}\`: ` : ""; lines.push(`- ${icon}${prefix}${warning.message}`); if (includeSuggestions) { if (warning.suggestedValues && warning.suggestedValues.length > 0) lines.push(` Suggested: ${warning.suggestedValues.join(", ")}`); else if (warning.suggestion) lines.push(` Suggestion: ${warning.suggestion}`); } } } if (includeTips && result.tips && result.tips.length > 0) { if (lines.length > 0) lines.push(""); lines.push("**Tips:**"); for (const tip of result.tips) { const icon = includeIcons ? "💡 " : ""; lines.push(`- ${icon}${tip}`); } } return lines.join("\n"); } //#endregion export { formatValidationMessages };