Permalink
Browse files

Added a compatibility layer

  • Loading branch information...
Baggz committed Mar 7, 2012
1 parent 38db00e commit c4889d15662ca1db013c5406cee8efe1a66d7731
Showing with 25 additions and 21 deletions.
  1. +25 −21 src/amanda.js
View
@@ -1,36 +1,40 @@
var tmpValidators = {};
+var Amanda = function(engine) {
+
+ this.engine = engine;
+ this.validate = Amanda.validate;
+ this.addValidator = Amanda.addValidator;
+
+};
+
/**
* Amanda
*
* @constructor
* @param {string} engine
*/
-var Amanda = {
-
- validate: function(instance, schema, options, callback) {
-
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
-
- each(tmpValidators, engines.json.addValidator);
+Amanda.validate = function(instance, schema, options, callback) {
- return engines.json.validate(instance, schema, options, callback);
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
- },
+ each(tmpValidators, engines.json.addValidator);
- /**
- * AddValidator
- *
- * @param {string} validatorName
- * @param {function} validatorFn
- */
- addValidator: function(validatorName, validatorFn) {
- tmpValidators[validatorName] = validatorFn;
- }
+ this.engine = this.engine || 'json';
+ return engines[this.engine].validate(instance, schema, options, callback);
+};
+/**
+ * AddValidator
+ *
+ * @param {string} validatorName
+ * @param {function} validatorFn
+ */
+Amanda.addValidator = function(validatorName, validatorFn) {
+ tmpValidators[validatorName] = validatorFn;
};

0 comments on commit c4889d1

Please sign in to comment.