forked from framasoft/ep_mypads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.js
35 lines (30 loc) · 904 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* # Helpers Module
*
* This module contains all transversal helpers functions.
*/
module.exports = (function () {
'use strict';
// Dependencies
var ld = require('lodash');
/**
* ## lodash mixins
*
* Here are lodash user extensions for MyPads.
*
* ### isEmail
*
* `isEmail` checks if given string is an email or not. It takes a value and
* returns a boolean.
*
* For reference, used regular expression is :
* /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
*/
ld.mixin({ isEmail: function (val) {
var rg = new RegExp(['[a-z0-9!#$%&\'*+/=?^_`{|}~-]+',
'(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9]',
'(?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9]',
'(?:[a-z0-9-]*[a-z0-9])?'].join(''));
return (ld.isString(val) && rg.test(val));
}});
}).call(this);