Socket
Socket
Sign inDemoInstall

ajv

Package Overview
Dependencies
Maintainers
1
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv - npm Package Compare versions

Comparing version 0.5.12 to 0.6.0

5

lib/ajv.js

@@ -161,5 +161,6 @@ 'use strict';

resolve.ids.call(self, schema);
var localRefs = resolve.ids.call(self, schema);
var validate = self._refs[id] = compileSchema.call(self, schema);
var validate = compileSchema.call(self, schema, undefined, localRefs);
if (id[0] != '#') self._refs[id] = validate;
self._cache.put(str, validate);

@@ -166,0 +167,0 @@

8

lib/compile/index.js

@@ -15,3 +15,3 @@ 'use strict';

function compile(schema, root) {
function compile(schema, root, localRefs) {
var self = this

@@ -79,2 +79,8 @@ , refVal = [ undefined ]

if (v) return addLocalRef(ref, v);
var localSchema = localRefs[ref];
if (localSchema) {
var v = compile.call(self, localSchema, root, localRefs);
if (v) return addLocalRef(ref, v);
}
}

@@ -81,0 +87,0 @@

@@ -27,4 +27,5 @@ 'use strict';

var v;
if (typeof schema == 'function') v = this._refs[ref] = schema;
else if (schema) v = this._refs[ref] = compile.call(this, schema, root);
if (typeof schema == 'function') v = schema;
else if (schema) v = compile.call(this, schema, root);
if (v && ref[0] != '#') this._refs[ref] = v;
util.copy(currentRoot, root);

@@ -120,27 +121,34 @@ return v;

var id = normalizeId(schema.id);
var localRefs = {};
_resolveIds.call(this, schema, getFullPath(id, false), id);
}
return localRefs;
function _resolveIds(schema, fullPath, baseId) {
if (Array.isArray(schema))
for (var i=0; i<schema.length; i++)
_resolveIds.call(this, schema[i], fullPath+'/'+i, baseId);
else if (schema && typeof schema == 'object') {
if (typeof schema.id == 'string') {
var id = baseId = baseId
? url.resolve(baseId, schema.id)
: normalizeId(schema.id);
function _resolveIds(schema, fullPath, baseId) {
if (Array.isArray(schema))
for (var i=0; i<schema.length; i++)
_resolveIds.call(this, schema[i], fullPath+'/'+i, baseId);
else if (schema && typeof schema == 'object') {
if (typeof schema.id == 'string') {
var id = baseId = baseId
? url.resolve(baseId, schema.id)
: getFullPath(schema.id);
var refVal = this._refs[id];
if (typeof refVal == 'string') refVal = this._refs[refVal];
if (refVal && refVal.schema) {
if (!equal(schema, refVal.schema))
throw new Error('id "' + id + '" resolves to more than one schema');
} else if (id != normalizeId(fullPath))
this._refs[id] = fullPath;
var refVal = this._refs[id];
if (typeof refVal == 'string') refVal = this._refs[refVal];
if (refVal && refVal.schema) {
if (!equal(schema, refVal.schema))
throw new Error('id "' + id + '" resolves to more than one schema');
} else if (id != normalizeId(fullPath)) {
if (id[0] == '#') {
if (localRefs[id] && !equal(schema, localRefs[id]))
throw new Error('id "' + id + '" resolves to more than one schema');
localRefs[id] = schema;
} else
this._refs[id] = fullPath;
}
}
for (var key in schema)
_resolveIds.call(this, schema[key], fullPath+'/'+escapeFragment(key), baseId);
}
for (var key in schema)
_resolveIds.call(this, schema[key], fullPath+'/'+escapeFragment(key), baseId);
}
}
{
"name": "ajv",
"version": "0.5.12",
"version": "0.6.0",
"description": "Another JSON Schema Validator",

@@ -5,0 +5,0 @@ "main": "lib/ajv.js",

@@ -45,4 +45,3 @@ 'use strict';

skip: [
'optional/zeroTerminatedFloats',
'schemas/complex'
'optional/zeroTerminatedFloats'
],

@@ -49,0 +48,0 @@ cwd: __dirname,

[
{
"skip": true,
"description": "IDs in refs without root id (#1)",

@@ -5,0 +4,0 @@ "schema": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc