var _ = require('underscore');

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);

    },
    isValidRequired: function(value) {
        if (value === undefined || value === "") {
            return false;
        }
        return true;

    },

    safeString: function(item) {
        if (!_.isString(item)) {
            return "";
        } else {
            return item;
        }

    }

};

module.exports = Validations;