Comparing version 0.4.12 to 0.4.14
@@ -26,3 +26,2 @@ 'use strict'; | ||
this._refs = {}; | ||
this._missing = {}; | ||
this._byJson = {}; | ||
@@ -169,6 +168,5 @@ this._formats = formats(this.opts.format); | ||
function checkUnique(id) { | ||
var schemaRef = self._refs[id]; | ||
if (self._schemas[id] || (schemaRef && !schemaRef.missing)) | ||
if (self._schemas[id] || self._refs[id]) | ||
throw new Error('schema with key or id "' + id + '" already exists'); | ||
} | ||
} |
@@ -75,4 +75,2 @@ 'use strict'; | ||
return addLocalRef(ref, root.refVal[rootRefId]); | ||
else if (ref == '#' || ref =='#/') | ||
return 'root.refVal[0]'; | ||
} | ||
@@ -79,0 +77,0 @@ var v = resolve.call(self, compile, root, ref); |
@@ -13,3 +13,2 @@ 'use strict'; | ||
resolve.ids = resolveIds; | ||
resolve.missing = resolveMissing; | ||
@@ -41,9 +40,4 @@ | ||
if (refPath !== baseId) { | ||
// rootSchema = undefined; TODO this breaks resolution in meta-schema | ||
var refVal = this._refs[refPath]; | ||
if (typeof refVal == 'string') refVal = this._refs[refVal]; | ||
// { | ||
// if (this._refs[refVal]) refVal = this._refs[refVal]; | ||
// else refVal = resolve.call(this, rootSchema, refVal); | ||
// } | ||
if (typeof refVal == 'function') util.copy(refVal, root); | ||
@@ -61,5 +55,10 @@ else { | ||
} | ||
p.hash = p.hash || ''; | ||
if (p.hash.slice(0,2) != '#/') return; | ||
var parts = p.hash.split('/'); | ||
return getJsonPointer.call(this, p, baseId, root); | ||
} | ||
function getJsonPointer(parsedRef, baseId, root) { | ||
parsedRef.hash = parsedRef.hash || ''; | ||
if (parsedRef.hash.slice(0,2) != '#/') return; | ||
var parts = parsedRef.hash.split('/'); | ||
var schema = root.schema; | ||
@@ -144,5 +143,2 @@ | ||
this._refs[id] = fullPath; | ||
// TODO check and resolve missing | ||
} | ||
@@ -153,6 +149,1 @@ for (var key in schema) | ||
} | ||
function resolveMissing(schema, schemaRef) { | ||
} |
{{# def.definitions }} | ||
{{# def.setup:'$ref' }} | ||
{{## def.validateRef:_v: | ||
if (!{{# def._validateRef:_v }}) { | ||
if (validate.errors === null) validate.errors = {{=_v}}.errors; | ||
else validate.errors = validate.errors.concat({{=_v}}.errors); | ||
errors = validate.errors.length; | ||
} {{? $breakOnError }} else { {{?}} | ||
#}} | ||
{{## def._validateRef:_v: {{=_v}}({{=$data}}, (dataPath || '') + {{= it.errorPath }}) #}} | ||
{{? $schema == '#' || $schema == '#/' }} | ||
{{? it.isRoot }} | ||
{{? $breakOnError && it.wasTop }} | ||
if (!validate({{=$data}}, (dataPath || '') + {{= it.errorPath }})) | ||
if (!{{# def._validateRef:'validate' }}) | ||
return false; | ||
@@ -12,6 +22,5 @@ else { | ||
var errors{{=$lvl}} = validate.errors; | ||
if (!validate({{=$data}}, (dataPath || '') + {{= it.errorPath }})) { | ||
if (errors{{=$lvl}} !== null) { | ||
if (!{{# def._validateRef:'validate' }}) { | ||
if (errors{{=$lvl}} !== null) | ||
validate.errors = errors{{=$lvl}}.concat(validate.errors); | ||
} | ||
errors = validate.errors.length; | ||
@@ -23,7 +32,3 @@ } {{? $breakOnError }} else { {{?}} | ||
var {{=$v}} = root.refVal[0]; | ||
if (!{{=$v}}({{=$data}}, (dataPath || '') + {{= it.errorPath }})) { | ||
if (validate.errors === null) validate.errors = {{=$v}}.errors; | ||
else validate.errors = validate.errors.concat({{=$v}}.errors); | ||
errors = validate.errors.length; | ||
} {{? $breakOnError }} else { {{?}} | ||
{{# def.validateRef:$v }} | ||
{{?}} | ||
@@ -38,8 +43,4 @@ {{??}} | ||
var {{=$v}} = {{=$refVal}}; | ||
if (!{{=$v}}({{=$data}}, (dataPath || '') + {{= it.errorPath }})) { | ||
if (validate.errors === null) validate.errors = {{=$v}}.errors; | ||
else validate.errors = validate.errors.concat({{=$v}}.errors); | ||
errors = validate.errors.length; | ||
} {{? $breakOnError }} else { {{?}} | ||
{{# def.validateRef:$v }} | ||
{{?}} | ||
{{?}} |
{ | ||
"name": "ajv", | ||
"version": "0.4.12", | ||
"version": "0.4.14", | ||
"description": "Another JSON schema Validator", | ||
@@ -5,0 +5,0 @@ "main": "lib/ajv.js", |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// 'schemas/advanced' | ||
'issues/12_restoring_root_after_resolve' | ||
// 'issues/12_restoring_root_after_resolve' | ||
// ]; | ||
@@ -82,3 +82,3 @@ | ||
var valid = validate(test.data); | ||
// console.log('result', valid, test.valid, validate.errors); | ||
// if (valid !== test.valid) console.log('result', valid, test.valid, validate.errors); | ||
assert.equal(valid, test.valid); | ||
@@ -85,0 +85,0 @@ if (valid) assert(validate.errors === null); |
@@ -5,3 +5,2 @@ [ | ||
"schema": { | ||
"id": "http://example.com", | ||
"type": "array", | ||
@@ -8,0 +7,0 @@ "items": { "$ref": "#transaction" }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
270357
8094