Build README

This commit is contained in:
Angelos Chalaris
2017-12-14 11:24:46 +02:00
parent ffa7a8fdd0
commit 3fa2d41ff3
2 changed files with 18 additions and 7 deletions

View File

@ -73,6 +73,7 @@
* [Unique values of array](#unique-values-of-array) * [Unique values of array](#unique-values-of-array)
* [URL parameters](#url-parameters) * [URL parameters](#url-parameters)
* [UUID generator](#uuid-generator) * [UUID generator](#uuid-generator)
* [Validate email](#validate-email)
* [Validate number](#validate-number) * [Validate number](#validate-number)
* [Value or default](#value-or-default) * [Value or default](#value-or-default)
@ -768,6 +769,17 @@ const uuid = _ =>
// uuid() -> '7982fcfe-5721-4632-bede-6000885be57d' // uuid() -> '7982fcfe-5721-4632-bede-6000885be57d'
``` ```
### Validate email
Use a regular experssion to check if the email is valid.
Returns `true` if email is valid, `false` if not.
```js
const validateEmail = str =>
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(str);
// validateEmail(mymail@gmail.com) -> true
```
### Validate number ### Validate number
Use `!isNaN` in combination with `parseFloat()` to check if the argument is a number. Use `!isNaN` in combination with `parseFloat()` to check if the argument is a number.

View File

@ -1,11 +1,10 @@
### Validate email ### Validate email
Use a regular experssion to check if the email is valid. Use a regular experssion to check if the email is valid.
Returns `true` if email is valid, `false` if not. Returns `true` if email is valid, `false` if not.
```js ```js
const validateEmail = str => const validateEmail = str =>
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(str); /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(str);
// isemail(mymail@gmail.com) -> true // validateEmail(mymail@gmail.com) -> true
``` ```