From dc10816fc3419bd4bda5f8f90d96aa6e73b7f191 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sun, 20 Mar 2016 18:12:14 +0000 Subject: [PATCH] refactor using options ignored for meta schemas --- lib/ajv.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/ajv.js b/lib/ajv.js index 1da6fea..996198c 100644 --- a/lib/ajv.js +++ b/lib/ajv.js @@ -59,14 +59,16 @@ function Ajv(opts) { this._addSchema = _addSchema; this._compile = _compile; + opts.loopRequired = opts.loopRequired || Infinity; + if (opts.async || opts.transpile) async.setup(opts); + if (opts.beautify === true) opts.beautify = { indent_size: 2 }; + if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true; + this._metaOpts = getMetaSchemaOptions(); + addInitialSchemas(); if (opts.formats) addInitialFormats(); - if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true; if (opts.v5) v5.enable(this); - if (typeof self._opts.meta == 'object') addMetaSchema(self._opts.meta); - opts.loopRequired = opts.loopRequired || Infinity; - if (opts.beautify) opts.beautify = opts.beautify === true ? { indent_size: 2 } : opts.beautify; - if (opts.async || opts.transpile) async.setup(opts); + if (typeof opts.meta == 'object') addMetaSchema(opts.meta); /** @@ -87,7 +89,7 @@ function Ajv(opts) { } var valid = v(data); - if (v.async) return opts.async == '*' ? co(valid) : valid; + if (v.async) return self._opts.async == '*' ? co(valid) : valid; self.errors = v.errors; return valid; } @@ -282,27 +284,17 @@ function Ajv(opts) { } schemaObj.compiling = true; - var currentOpts = {}, i, opt; + var currentOpts; if (schemaObj.meta) { - for (i=0; i