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

This commit is contained in:
Cristian Lupu
2020-10-30 18:11:51 +02:00
parent 2190b92e1b
commit 09d38fe959

View File

@ -1,11 +1,22 @@
/*
function that takes a string input and return either it is true of false
a valid email address
e.g.: mahfoudh.arous@gmail.com -> true
e.g.: mahfoudh.arous@helsinki.edu -> 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('mahfoudh.arous@gmail.com')
* true
* > validateEmail('mahfoudh.arous@helsinki.edu')
* 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.')