(function($) {

    var validation = function() {
        
        var rules = {  // Private object
            
            email : {
               check: function(value) {
                   
                   if(value) {
                      var pattern = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}$/;
                       return testValue(value, pattern);
                   }
                   return false;
               },
               msg : ""
            },
            required : {
                
               check: function(value) {

                   if(value) {
                       return true;
                   }
                   else {
                       return false;
                   }
               },
               msg : ""
            }
        }
        var testValue = function(value, pattern) {   // Private Method
            return pattern.test(value);
        }
        return { // Public methods
            
            addRule : function(name, rule) {

                rules[name] = rule;
            },
            getRule : function(name) {

                return rules[name];
            }
        }
    }
    //A new instance of our object in the jQuery namespace.
    $.validation = new validation();
})(jQuery); 