2015-03-14 08:17:06 +01:00
|
|
|
var _ = require('underscore');
|
|
|
|
|
|
2015-03-02 07:49:36 +01:00
|
|
|
var Validations = {
|
2015-03-14 08:17:06 +01:00
|
|
|
_emailRe: /^(([^<>()[\]\\.,;:\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,}))$/,
|
|
|
|
|
isValidEmail: function(value) {
|
|
|
|
|
return this._emailRe.test(value);
|
2015-03-02 07:49:36 +01:00
|
|
|
|
2015-03-14 08:17:06 +01:00
|
|
|
},
|
2015-03-02 07:49:36 +01:00
|
|
|
isValidRequired: function(value) {
|
2015-03-14 08:17:06 +01:00
|
|
|
if (value === undefined || value === "") {
|
2015-03-02 07:49:36 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
2015-03-14 08:17:06 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
safeString: function(item) {
|
|
|
|
|
if (!_.isString(item)) {
|
|
|
|
|
return "";
|
|
|
|
|
} else {
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-02 07:49:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-14 08:17:06 +01:00
|
|
|
module.exports = Validations;
|