Created
May 23, 2014 12:23
-
-
Save PawelGerr/7fe78fb5fb3e9b55205e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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