Skip to content

Commit 71192ab

Browse files
authored
Merge pull request #532 from Khez/string-validate-email
#142 #461 Adding Doctests to String/ValidateEmail.js
2 parents d8395e7 + 09d38fe commit 71192ab

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

String/ValidateEmail.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
/*
2-
function that takes a string input and return either it is true of false
3-
a valid email address
4-
e.g.: [email protected] -> true
5-
e.g.: [email protected] -> true
6-
e.g.: mahfoudh.arous.com ->false
2+
Function that takes a string input and return either true or false
3+
If it is a valid email address
74
*/
85

6+
/*
7+
* Doctests
8+
*
9+
* > validateEmail('[email protected]')
10+
* true
11+
* > validateEmail('[email protected]')
12+
* true
13+
* > validateEmail('mahfoudh.arous.com')
14+
* false
15+
* > validateEmail('')
16+
* ! TypeError
17+
* > validateEmail(null)
18+
* ! TypeError
19+
*/
920
const validateEmail = (str) => {
1021
if (str === '' || str === null) {
1122
throw new TypeError('Email Address String Null or Empty.')

0 commit comments

Comments
 (0)