- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2020 11:20 PM
I need to validate the email. im trying to write on before script in a transform to validate email field and my target table is sys_user.In the source table the field is u_email.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2020 12:07 AM
You can use the email type field or variable which will automatically validate the email address
or
try this script :
var email = source.u_email;
if (!email || email.trim().length <= 0)
return true;
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!re.test(email))
{
ignore =true;
}
else
{
ignore = false;
}
or you can follow this link :
mark my answer correct and helpful if it helps you !
regards,
apeksha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2020 11:28 PM
Hi avinash ,
could you please elaborate the issue , is there any issue with the script ? or do you need some help with script ?
regards,
apeksha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2020 11:33 PM
Hi again ,
follow this link it will surely help you :
regards,
apeksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2020 11:36 PM
Im trying the below script but it is not working
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here//Email validation
var errorFlag = false;
var email = source.u_email;
var errorMessage;
errorMessage = "Row("+(source.sys_import_row).toString() + ") ";
if(email.nil() || email == ""){
//do nothing
}
else if (!validateEmail(email)) {
errorMessage += "Please check Email ID format";
errorFlag = true;
}
// Email Validation Field
function validateEmail(field) {
var email = field;
if (!email || email.trim().length <= 0)
return true;
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!re.test(email)) {
return false;
}
return true;
}
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2020 12:03 AM
You can use the email type field or variable which will automatically validate the email address
or
try this script :
var email = u_email;
if (!email || email.trim().length <= 0)
return true;
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!re.test(email))
{
ignore =true;
}
else
{
ignore = false;
}
or you can follow this link :
mark my answer correct and helpful if it helps you !
regards,
apeksha