From 09d38fe9595104b69c5f099623c5ec45a8292bba Mon Sep 17 00:00:00 2001 From: Cristian Lupu Date: Fri, 30 Oct 2020 18:11:51 +0200 Subject: [PATCH] #142 #461 Adding Doctests to String/ValidateEmail.js --- String/ValidateEmail.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/String/ValidateEmail.js b/String/ValidateEmail.js index 1e1ace2f1..729685fec 100644 --- a/String/ValidateEmail.js +++ b/String/ValidateEmail.js @@ -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.')