mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
@ -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.')
|
||||
|
Reference in New Issue
Block a user