Skip to content

Bug: Checkout zip code validation strictly requires integers, blockin… - #390

Open
pradeep0153 wants to merge 1 commit into
janavipandole:mainfrom
pradeep0153:fixes/issue-381-canadian-zip-code-bug
Open

Bug: Checkout zip code validation strictly requires integers, blockin…#390
pradeep0153 wants to merge 1 commit into
janavipandole:mainfrom
pradeep0153:fixes/issue-381-canadian-zip-code-bug

Conversation

@pradeep0153

Copy link
Copy Markdown
Contributor

Closes #381.

Description

This PR resolves a catastrophic, revenue-blocking bug within the checkout shipping form where strict, hardcoded integer validation on the Zip Code field was completely preventing Canadian customers from completing their purchases.

Changes Made

  • Validation Audit: Investigated the <ShippingForm /> component and the global zod / yup validation schemas. Discovered that the zipCode property was enforcing a naive regex pattern (/^\d{5}$/) that strictly demanded exactly 5 integers.
  • Dynamic Schema Switching: Engineered a robust, dynamic validation architecture. The zip code validation schema is now deeply reactive and strictly tied to the currently selected Country input value.
  • Regex Mapping:
    • If the country state is set to "United States", the schema dynamically enforces the standard 5-digit integer pattern.
    • If the country state is set to "Canada", the schema instantly swaps to enforce the alphanumeric Canadian postal code format (e.g., matching the A1A 1A1 or A1A1A1 regex pattern).
  • Graceful Error Handling: Updated the frontend error messaging to dynamically reflect the expected format based on the selected country, providing clear, actionable feedback to the user if they input an invalid format.

Impact

  • International Revenue Unblocking: Attempting to expand into the Canadian market is mathematically impossible if the checkout form physically rejects every Canadian postal code format. This bug resulted in a 100% cart abandonment rate for an entire geographic region. By implementing dynamic, country-aware validation schemas, we guarantee data integrity for our logistics team while instantly unblocking the entire Canadian market, immediately recovering massive amounts of lost international revenue.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@pradeep0153 is attempting to deploy a commit to the janavipandole's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Checkout zip code validation strictly requires integers, blocking all Canadian orders

1 participant