Skip to content

#142 #461 Adding Doctests to String/ValidateEmail.js #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions String/ValidateEmail.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
/*
function that takes a string input and return either it is true of false
a valid email address
e.g.: [email protected] -> true
e.g.: [email protected] -> true
e.g.: mahfoudh.arous.com ->false
Function that takes a string input and return either true or false
If it is a valid email address
*/

/*
* Doctests
*
* > validateEmail('[email protected]')
* true
* > validateEmail('[email protected]')
* true
* > validateEmail('mahfoudh.arous.com')
* false
* > validateEmail('')
* ! TypeError
* > validateEmail(null)
* ! TypeError
*/
const validateEmail = (str) => {
if (str === '' || str === null) {
throw new TypeError('Email Address String Null or Empty.')
Expand Down