Files

28 lines
647 B
JavaScript
Raw Permalink Normal View History

var _ = require('underscore');
2015-03-02 07:49:36 +01:00
var Validations = {
_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-02 07:49:36 +01:00
isValidRequired: function(value) {
if (value === undefined || value === "") {
2015-03-02 07:49:36 +01:00
return false;
}
return true;
},
safeString: function(item) {
if (!_.isString(item)) {
return "";
} else {
return item;
}
2015-03-02 07:49:36 +01:00
}
};
module.exports = Validations;