Skip to content

Instantly share code, notes, and snippets.

@PawelGerr
Created May 23, 2014 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PawelGerr/7fe78fb5fb3e9b55205e to your computer and use it in GitHub Desktop.
Save PawelGerr/7fe78fb5fb3e9b55205e to your computer and use it in GitHub Desktop.
(function () {
'use strict';
/**
* @constructor
*/
function TtValidationDefinitionProvider() {
var lookup = {};
this.register = function (key, validationDefinition) {
if (!key)
throw new Error('Key must not be null.');
if (!validationDefinition)
throw new Error('Validation definition must not be null.');
if (lookup[key])
throw new Error('A validation definition with the same key has been registered already.');
lookup[key] = validationDefinition;
};
this.$get = function () {
return new TtValidationDefinition(lookup);
};
};
/**
* @param {*} lookup
* @constructor
*/
function TtValidationDefinition(lookup) {
this.get = function (key) {
if (!key)
return undefined;
return lookup[key];
}
};
app.module.provider('ttValidationDefinition', TtValidationDefinitionProvider);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment