Skip to main content
Question

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


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.

Did this topic help you find an answer to your question?

8 replies

Badger
Forum|alt.badge.img+5
  • New
  • 134 replies
  • November 25, 2024

@Andrew Marcroft 

The python function would be the simplest.

Otherwise, I feel you’ll probably need a very long complex filter looking for the same things.
 

import re

email = input_data['email'] 

# Simple email pattern
email_regex = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"

# Validate email
is_valid = re.match(email_regex, email) is not None

# Output the result
output = {"is_valid": is_valid}

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 25, 2024

Hi ​@Andrew Marcroft 

Try this Zap step: Formatter > Text > Extract Email Address

Help: https://zapier.com/apps/formatter/help


Badger
Forum|alt.badge.img+5
  • New
  • 134 replies
  • November 25, 2024

@Troy Tessalone 

I thought of that but Null values have always caused my zaps to crash. How would you account for that if it returned the null value because the email wasn’t present?


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 25, 2024

@Badger 

Add a Filter step to check for the existence of an output variable value from the Formatter step: https://zapier.com/apps/filter/help

 

Also, Formatter > Text > Default Value

Could be used to set a dummy value.

 


Badger
Forum|alt.badge.img+5
  • New
  • 134 replies
  • November 25, 2024

@Troy Tessalone 

Thanks. 

I have a bias for code blocks don’t always see you can just stack up tasks. 🙄


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 25, 2024

@Badger 

Depends on the use case for the better approach.

Code steps count as 1 Task in Zap Runs.

Formatter Zap steps count as 0 Tasks in Zap Runs.

Other native Zap apps that count as 0 Tasks in Zap Runs:

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 25, 2024

@Badger 

Another thing to keep in mind is the audience of the topic.

The average Zapier user is true no-code.

Code steps are low-code and often foreign/scary to the average Zapier user.


Badger
Forum|alt.badge.img+5
  • New
  • 134 replies
  • November 25, 2024

@Troy Tessalone 

I didn’t realise they were free. I don’t think any tasks were when I started building for my friend years ago. 
I also didn’t think about the audience not liking code, I love it especially with the new AI tools making it so easy.

Another black mark my part.  

Thank you, I learnt something useful today.