Need to know email address validation logic

Hi,

I need to setup a logic to filter out only valid email address, might use that logic in filters, conditional or mappers. logic should able decide which email address valid.

For ex : test@test687 is invalid and test@test687.com or test@test687.edu etc are valid

Thanks

What about complex domains such as country identified like in.company.com?

Hey @vaidyarm ,

You can use regex:

$email.match(/^[\w-.]+@([\w-]+.)+[\w-]{2,4}$/g)

Regards,
Bojan

This did not work, used it for the below invalid id’s but do not work

automatedclean@00d5g000005evyzea4
autoproc@00d5g000005evyzea4
noreply@00d5g000005evyzea4

Yes if such should be allowed

Here is the input:

image

And the result:

image

So I gave you the logic for matching a correct format of an email. I you want to stop the pipeline, or throw an error, than you have to make some adjustments.

For example:

$email.match(/^[\w-.]+@([\w-]+.)+[\w-]{2,4}$/g) == null ? “fail” : “pass” if you want to use expressions. Other way I can think of is a Data Validator. Select Pattern as a Constraint and enter the regex into Constraint value.

I tried it via the below test pipeline but it does not work, not sure what I am doing wrong

Email Validator_2021_05_20.slp (6.5 KB)

The data format you are streaming is wrong. The data in this pipeline is a re-formated sample from your data.

EmailValidation.slp (3.3 KB)

1 Like

That work quite great!! thanks a lot

would there be anything required to filter out below types of id’s also ?
complex domains such as country identified like @in.company.com

Update the regex with this one, this is much more precise. There are edge cases which the previous regex can pass, this one won’t. About the complex domains, it would take much more regex tweaking, because after all , these domains are regular, correct, only more complex than the others.

Email Validator2_2021_05_21.slp (3.5 KB)

1 Like

Thanks, A Lot, This one is much better covers a lot of varying emails

1 Like

@vaiyarm -

You can do a DuckDuckGo Search (or snooptastic Google, if you prefer) on “e-mail address validation regex” (try removing the word regex or replacing with the full word, or the word “pattern” or “parsing”) and you should get a lot of hits. The most comprehensive validator that I’ve found was written in C# for CLR / dotNet: it could handle ALL valid internet e-mail addresses, including those with complex domain names.

That particular regex had several drawbacks:

  • uses C# regex syntax, and requires translation to Javascript .
  • excessively long regex (in the neighborhood of 200-300 characters!)
  • thus incredibly complex and difficult to proofread or to troubleshoot.

Personally, I’d prefer having to copy a hundred lines of parsing code (if relatively straightforward and clear) than to try to get such a fierce regex working. It can, however, be done!

Try reading the below for more reasons why you might want to use a real parser and not a regex…