Five 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!!

1 ACCEPTED SOLUTION

Accepted Solutions
Thirteen Stars TRF
Thirteen 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
9 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
Thirteen Stars TRF
Thirteen 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
Fifteen Stars

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.

Rilhia Solutions
Five 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?
Thirteen Stars TRF
Thirteen 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
Five 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?
Five 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?
Fifteen Stars

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)

 

Rilhia Solutions
Thirteen Stars TRF
Thirteen Stars

Re: Email Validation in talend

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

checkEmail.isEmailValid(row1.yourEmailField)

TRF