Email Validation in talend

Seven Stars

Email Validation in talend

 how to verify that the email address column's  data is having @ or [.] if not then load rejected data on diferent table.

please help!!


Accepted Solutions
Sixteen Stars TRF
Sixteen Stars

Re: Email Validation in talend

In the Repository, right click on Code, create a folder (here called "custom") then right click on "custom" and create a routine then past the code from my previous answer.

Here is what your screen should look like:

Capture.PNG

 


TRF

View solution in original post


All Replies
Community Manager

Re: Email Validation in talend

Hi
Create a user routine and define the function to validate the email address, and call the user routine on tFilterRow to filter the valid email address. If you just want to simply check the email address if it is having @ or ., using this expression on tFilterRow:
input_row.emailColumn.contains("@")||input_row.emailColumn.contains(".")

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Sixteen Stars TRF
Sixteen Stars

Re: Email Validation in talend

@vitspltalend, having an @ or a . (dot) is not enough to be a valid email.

The following "@@@@...." matches the rule but is not a valid email address.

As suggested by @shong, use a user defined routine to check the email validity.

It should look like this one:

package routines;
import java.util.regex.*;
public class checkEmail {
    public static boolean isEmailValid(String email) {
    	String regex = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$";
    	Pattern pattern = Pattern.compile(regex);
    	Matcher matcher = pattern.matcher(email);
    	return matcher.matches();
    }
}

TRF
Community Manager

Re: Email Validation in talend

That's a good shout by @TRF. As an addition to that (he should get the solution on this), Talend supplies the Apache Commons libraries which have hundreds of really useful, efficient and community (Java community) checked/built solutions. The Apache Commons Validator library comes with a whole host of validation methods for Emails, Phone Numbers, URLs, etc, etc. You should take a look.

Seven Stars

Re: Email Validation in talend

thanks @shong and @TRF, actually i am new in talend so, can you please tell me the whole process like where i can create user defined routine and which component i can use?
Sixteen Stars TRF
Sixteen Stars

Re: Email Validation in talend

In the Repository, right click on Code, create a folder (here called "custom") then right click on "custom" and create a routine then past the code from my previous answer.

Here is what your screen should look like:

Capture.PNG

 


TRF

View solution in original post

Highlighted
Seven Stars

Re: Email Validation in talend

hello shong can u plz tell me what is the process to call the user routine on tFilterrow to filter the valid email address?
Seven Stars

Re: Email Validation in talend

hello @TRF can u plz tell me what is the process to call the user routine on tFilterrow to filter the valid email address?
Community Manager

Re: Email Validation in talend

This tutorial (https://help.talend.com/reader/jomWd_GKqAmTZviwG_oxHQ/O_Vnk3B4SbKXtF5gTQl2Gg) shows how to use the Advanced Mode (which is what you will need). To point to the routine, you will need to use something like this....

routines.YourRoutineClass.yourRoutineMethod(parameters)

 

Sixteen Stars TRF
Sixteen Stars

Re: Email Validation in talend

Use tFilter Advanced mode to write the appropriate expression such as:

checkEmail.isEmailValid(row1.yourEmailField)

TRF
One Star

Re: Email Validation in talend

Hello TRF,

 

Thanks for the Email Validation code.

 

I am using for the same reason in my peoject but there is something going wrong with this. getting error.

will you help me ?

 

Error : The public type checkEmail must be defined in its own file

 

screen shot is attached.

 

 

 

Six Stars

Re: Email Validation in talend

Hi @Shri_Kul1 ,

 

You need to give the same name of the routine and the class ,

 

You have given as different names

 

CheckeMail 

checkEmail

 

Please update , it will work.

 

Thanks,

Mahesh

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog