normalizePhone (phone.js)

ai-voice-agent · phone-normalization, e164-format, indian-phone, voice

Indian-phone normalization. Shopify checkout returns phones in many shapes: +91 98765 43210 (formatted E.164) 919876543210 (no plus, with country code) 09876543210 (leading zero, no country code) 9876543210 (just 10 digits)

// Source: https://github.com/Nuraveda-Labs/ai-voice-agent | License: MIT | Copyright 2026 ai-voice-agent contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Indian-phone normalization.
 *
 * Shopify checkout returns phones in many shapes:
 *   +91 98765 43210      (formatted E.164)
 *   919876543210         (no plus, with country code)
 *   09876543210          (leading zero, no country code)
 *   9876543210           (just 10 digits)
 *   +91-98765-43210      (dashes)
 *   91 9876543210        (space)
 *
 * Vobiz SIP trunks require strict E.164 (+[1-9]\d{6,14}). Anything else silently
 * 4xx-drops at the carrier with no useful signal to the app.
 *
 * Returns:
 *   string — valid E.164 on success
 *   null   — couldn't parse into a valid number
 */
export

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

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

Get a free API key