One Star

[resolved] email validation

Hi!!!
I have a problem Smiley Sad
i want to validate email address before it get saved in database..seem to be easy but couldn implement..can anyone help??
thank you
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] email validation

Hi
On the output table, add a new field, let's call it isValid, boolean type, set the expression as:
(row22.emailaddress!=null) ? routines.CollectionUtils.isEmailValid(row22.emailaddress) : false
link the tMap to another tMap component, split the flow to two output tables, one for valid rows and another for invalid rows, add a filter expression on both of output tables,
for valid rows:
row23.isValid==true
for invalid rows:
row23.isValid==false
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
6 REPLIES
Community Manager

Re: [resolved] email validation

Hi
What is your validate rules? Would you like to reject the record and don't insert it into database if the email address is invalid?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] email validation

Hi shong!!
yes, if the email address is not valid,it should be rejected and should not process it further..
my job has a fileinputdelimited--tmap--tschemacheck--the main job.
the email should be rejected before the main job if it is invalid.
Thanks in advance.
One Star

Re: [resolved] email validation

Shong!
I did create a routine function and tried to use it..
code is,
public static boolean isEmailValid(String email) {

boolean b = Pattern.matches("^+@+\\.+$", email);

return b;
}
and in tmap i added the check in emailaddress column..
(row22.emailaddress!=null) ? routines.CollectionUtils.isEmailValid(row22.emailaddress) : null
but since my emailaddress column is string and the routine code is in boolean it doesnt seem to work..
can u tell me where am missing???
Thanks a lot
Community Manager

Re: [resolved] email validation

Hi
On the output table, add a new field, let's call it isValid, boolean type, set the expression as:
(row22.emailaddress!=null) ? routines.CollectionUtils.isEmailValid(row22.emailaddress) : false
link the tMap to another tMap component, split the flow to two output tables, one for valid rows and another for invalid rows, add a filter expression on both of output tables,
for valid rows:
row23.isValid==true
for invalid rows:
row23.isValid==false
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] email validation

Hi shong!!
Thanks a lot for the reply..it works!!!
I have one more serious issue unable to think a solution..
i want to populate two tables..
for instance,
emp table--> id name

1 ann
2 julie

details table --> id name detail
1 -- --
2 -- --
i want to create the rows in emp table, later need to take id of emp table and populate the same in details table.
not sure how to implement it..can do with the existing ids.but not with the one that is getting created instantly..
can u help me out in this?

Thank you!!
Community Manager

Re: [resolved] email validation

Hi
Glad to hear that you get it works now! But, please report a new topic for new question for better management.Smiley Wink
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business