Skip to content

Instantly share code, notes, and snippets.

@anilex
Created April 6, 2014 13:56
Show Gist options
  • Save anilex/10006385 to your computer and use it in GitHub Desktop.
Save anilex/10006385 to your computer and use it in GitHub Desktop.
/**
* Validate an email address.
*/
var validate_email_address = function(email_address) {
// TODO: This does not support using "+" in email addresses and it also seems
// to assume that the top level domain can only be three characters long.
// I coped this from somewhere. Need to revisit it. It works as a quick
// rule of thumb to reduce the amount of work that needs to be done by
// hand for the task at hand today.
if (/.+@.+\..+/i.test(email_address)) {
return(true);
} else {
return(false);
}
}
// Take an email address as command line parameter and log whether it's valid or not.
var email_address = process.argv[2];
if (validate_email_address(email_address)) {
console.log('valid: %s', email_address);
} else {
console.log('not valid: %s', email_address);
}
Copy link

ghost commented Apr 6, 2014

bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment