Question

Testing /validating and tidying/ensuring correct format for email address

  • 30 April 2024
  • 1 reply
  • 58 views

Is there a built in way in Zapier to test for the validity of an email addresses format?

I’m not trying to test the validity of an actual email address, ie that it is an active mailbox, rather just that it’s a legislate format.

So that the SAAS I’m trying to send it to won’t reject it.

I’d rather avoid building a Python function to do this if possible.

tThanks in advance.


1 reply

Yes, Zapier offers a built-in way to test the validity of an email address format without requiring custom code after crm data enrichment. You can use the Formatter by Zapier to validate email formats using a regular expression (regex). First, add an action step in your Zap and choose "Formatter by Zapier." Select the "Text" action event. Next, choose the "Transform" operation as "Extract Pattern." In the "Input" field, map the email address field you want to validate. In the "Pattern" field, enter a regex pattern for email validation, such as ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$. Run the test to see if the email addresses are extracted correctly. If the email address matches the pattern, it will be extracted; otherwise, it will return null or an empty string. Then, add a Filter step to allow the Zap to continue only if the Formatter step's output is not null or empty. This ensures only valid email addresses pass through to the next step.

If you need more complex validation, you can use the "Code by Zapier" action with JavaScript. Add an action step and choose "Code by Zapier." Select the "Run Javascript" action event. In the Code field, enter JavaScript code to validate the email format. For example:

const email = inputData.email;
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return { isValid: emailPattern.test(email) };

 

In the Input Data section, map the email field to the email input. Run the test to see if it correctly identifies valid and invalid email formats. Finally, add a Filter step to allow the Zap to continue only if isValid is true.

Reply