// Single source of truth for "is this a plausible email address" — used // client-side (checkout, newsletter forms) for immediate on-blur feedback // and server-side (newsletter subscribe route) as the same check, not a // second one that could drift out of sync. const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; export function isValidEmail(value: string): boolean { return EMAIL_PATTERN.test(value); } // Returns "" for valid, an error message otherwise. export function validateEmailFormat(value: string): string { if (!value.trim()) return "E-Mail-Adresse ist erforderlich."; return isValidEmail(value) ? "" : "Bitte eine gültige E-Mail-Adresse angeben."; }