Email Guards
FoundationValidation and sanitization utilities for email templates. Enforces safe hex colors, validates URLs (blocks javascript: and data:), normalizes recipient addresses, and clamps subject lines to SMTP-safe lengths.
core/email-guardsInstallation
1 · Add registry to components.json
2 · Install component
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
sanitizeEmailTemplateHex(input, fallback) | string → string | — | Only allows #rgb or #rrggbb, returns fallback otherwise. |
normalizeRecipientEmail(email, context) | string → string | — | Trims and validates a recipient address. |
requireHttpOrHttpsUrl(raw, label) | string → string | — | Blocks non-http(s) protocols. |
optionalHttpOrHttpsUrl(raw, label) | string | undefined | — | Like requireHttpOrHttpsUrl but accepts undefined/null. |
clampEmailSubjectLine(subject, maxLen?) | string → string | — | Truncates to 200 chars with ellipsis. |