Browse files

Amanda now exposes the methods of the selected engine

  • Loading branch information...
1 parent 53267f4 commit f883458b0cebd182a1ba4ac370d84361d809494a @Baggz committed Mar 12, 2012
Showing with 3 additions and 34 deletions.
  1. +3 −34 src/amanda.js
View
37 src/amanda.js
@@ -1,40 +1,9 @@
-var tmpValidators = {};
-
var Amanda = function(engine) {
- this.engine = engine;
- this.validate = Amanda.validate;
- this.addValidator = Amanda.addValidator;
-
-};
-
-/**
- * Amanda
- *
- * @constructor
- * @param {string} engine
- */
-Amanda.validate = function(instance, schema, options, callback) {
-
- if (typeof options === 'function') {
- callback = options;
- options = {};
+ if (!hasProperty(engines, engine)) {
+ throw new Error('The ‘' + engine + '’ engine is not supported. Please use a different one.');
}
- each(tmpValidators, engines.json.addValidator);
-
- this.engine = this.engine || 'json';
-
- return engines[this.engine].validate(instance, schema, options, callback);
-
-};
+ return engines[engine];
-/**
- * AddValidator
- *
- * @param {string} validatorName
- * @param {function} validatorFn
- */
-Amanda.addValidator = function(validatorName, validatorFn) {
- tmpValidators[validatorName] = validatorFn;
};

0 comments on commit f883458

Please sign in to comment.