I want to add validation for customer email domain in my javascript frontend code like the validtion there is in the checkout page for the customer email domain. how can i get this function? there is api?
Topic summary
A developer seeks to implement email domain validation in JavaScript frontend code, similar to the validation used on Shopify’s checkout page. They want to verify if email domains are legitimate, not just match specific patterns.
Key Points:
- Initial suggestion pointed to existing Shopify community discussions about domain-specific validation
- User clarified they need dynamic validation for any domain (checking if domains are real), not pattern matching
- Shopify does not provide a direct API for their internal checkout email validation logic
Proposed Solution:
- Integrate third-party service DeBounce for email validation
- Implementation involves API calls to verify email safety/validity
- Code snippet provided shows async function using DeBounce API endpoint
Status: Discussion appears resolved with a third-party workaround, though the native Shopify solution requested is unavailable.
This topic has already been discussed before on the Shopify community. If you could spend your valuable time on this conversation, then I believe you can get an answer.
https://community.shopify.com/post/2005607
If you don’t find your answer, then get back to me. I would like to guide you further.
Thanks for the reply, I read the answer but I don’t want to use a specific pattern.
I want the logic like on the checkout page that checks for every domain that can be given to it whether it is a real domain or not!
Is this possible?
Based on my research, unfortunately, Shopify doesn’t provide a direct API for accessing their internal email domain validation logic that’s used in the checkout. However, I can help with a third-party service, DeBounce Integration by integrating the DeBounce into your Shopify forms API and adding your domain to the approved domain lists.
Here is the detailed info: https://debounce.io/integrations/shopify/
You can explore this code for further info.
async function validateEmailWithAPI(email) {
try {
const response = await fetch(`https://api.debounce.io/v1/?api=${YOUR_API_KEY}&email=${email}`);
const result = await response.json();
return result.debounce.result === 'Safe';
} catch (error) {
console.error('Email validation error:', error);
return false;
}
}
I hope this could helps.