From 4f631e61b8c0503e74be56447e17170cbcf9e4eb Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Mon, 27 Feb 2017 00:18:42 +0000 Subject: [PATCH] feat: support $id, #384 --- lib/ajv.js | 44 ++- lib/compile/resolve.js | 21 +- lib/dot/validate.jst | 11 +- lib/refs/$data.json | 2 +- lib/refs/json-schema-draft-06.json | 4 +- spec/options.spec.js | 49 ++++ .../13_root_ref_in_ref_in_remote_ref.json | 21 +- .../issues/14_ref_in_remote_ref_with_id.json | 34 ++- .../issues/170_ref_and_id_in_sibling.json | 256 ++++++++++++------ spec/tests/issues/1_ids_in_refs.json | 57 ++-- spec/tests/issues/27_recursive_reference.json | 77 ++++-- .../issues/63_id_property_not_in_schema.json | 18 +- ...70_1_recursive_hash_ref_in_remote_ref.json | 14 +- 13 files changed, 439 insertions(+), 169 deletions(-) diff --git a/lib/ajv.js b/lib/ajv.js index 82af28c..dde836f 100644 --- a/lib/ajv.js +++ b/lib/ajv.js @@ -69,6 +69,7 @@ function Ajv(opts) { this._loadingSchemas = {}; this._compilations = []; this.RULES = rules(); + this._getId = chooseGetId(opts); opts.loopRequired = opts.loopRequired || Infinity; if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true; @@ -136,9 +137,10 @@ function addSchema(schema, key, _skipValidation, _meta) { for (var i=0; i