Created
April 6, 2014 13:56
-
-
Save anilex/10006385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bro