validateEmail (utils/checkoutUtils.ts)

Stirling-PDF · frontend/src/editor/proprietary/components/shared/stripeCheckout/utils/checkoutUtils.ts · typescript · MIT
payments

Validates email format and provides modal titles for checkout stages.

// Source: https://github.com/Stirling-Tools/Stirling-PDF | License: MIT | Copyright 2025 Stirling PDF Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { TFunction } from "i18next";
import i18n from "i18next";
import { CheckoutStage } from "@editor/components/shared/stripeCheckout/types/checkout";

/**
 * Validate email address format
 */
export const validateEmail = (
  email: string,
): { valid: boolean; error: string } => {
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  if (!emailRegex.test(email)) {
    return {
      valid: false,
      error: i18n.t(
        "signup.invalidEmail",
        "Please enter a valid email address",
      ),
    };
  }
  return { valid: true, error: "" };
};

/**
 * Get dynamic modal title based on current stage
 */
export c

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key