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.2.8 to 0.2.9

spec/tests/schemas/advanced.json

10

lib/compile/index.js

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

function compile(schema, _rootSchema) {
var self = this, refs = [], refIds = {};
var self = this, refVal = [], refs = {};
_rootSchema = _rootSchema || schema;

@@ -52,8 +52,8 @@

function resolveRef(ref) {
if (refIds[ref]) return refIds[ref];
if (refs[ref]) return refs[ref];
var v = resolve.call(self, compile, _rootSchema, ref);
if (v) {
var id = refs.length;
refs.push(v);
refIds[ref] = id;
var id = refVal.length;
refVal.push(v);
refs[ref] = id;
return id;

@@ -60,0 +60,0 @@ }

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

module.exports = function resolve(compile, rootSchema, ref) {
if (this._schemas[ref]) return this._schemas[ref];
if (ref[0] != '#') return;
if (this._schemas[ref]) return this._schemas[ref];
var schema = _resolve(rootSchema, ref);

@@ -23,3 +23,3 @@ if (schema) return this._schemas[ref] = compile.call(this, schema, rootSchema);

}
return schema;
if (schema != rootSchema) return schema;
}

@@ -26,0 +26,0 @@

{{# def.definitions }}
{{# def.setup:'$ref' }}
{{? $schema == '#' }}
{{? $schema == '#' || $schema == '#/' }}
var {{=$valid}} = validate({{=$data}}, (dataPath || '') + {{= it.errorPath }});
{{??}}
{{ $refId = it.resolveRef($schema); }}
{{? $refId === undefined }}
{{ $id = it.resolveRef($schema); }}
{{? $id === undefined }}
{{# def.error:'$ref' }}
var {{=$valid}} = false;
{{??}}
var {{=$valid}} = refs[{{=$refId}}]({{=$data}}, (dataPath || '') + {{= it.errorPath }});
if (!{{=$valid}}) validate.errors.push.apply(validate.errors, refs[{{=$refId}}].errors);
var {{=$valid}} = refVal[{{=$id}}]({{=$data}}, (dataPath || '') + {{= it.errorPath }});
if (!{{=$valid}}) validate.errors.push.apply(validate.errors, refVal[{{=$id}}].errors);
{{?}}
{{?}}
{
"name": "ajv",
"version": "0.2.8",
"version": "0.2.9",
"description": "Another JSON schema Validator",

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

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

// 'optional/format', 'optional/bignum',
// 'ref'
// 'ref',
// 'schemas/complex'
// ];

@@ -22,3 +23,4 @@

'refRemote',
'optional/zeroTerminatedFloats'
'optional/zeroTerminatedFloats',
'schemas/complex'
];

@@ -52,6 +54,7 @@

files.forEach(function (file) {
if (ONLY_RULES && ONLY_RULES.indexOf(file.name) == -1) return;
if (SKIP_RULES && SKIP_RULES.indexOf(file.name) >= 0) return;
var skip = (ONLY_RULES && ONLY_RULES.indexOf(file.name) == -1) ||
(SKIP_RULES && SKIP_RULES.indexOf(file.name) >= 0);
// if (skip) return;
describe(file.name, function() {
(skip ? describe.skip : describe) (file.name, function() {
var testSets = require(file.path);

@@ -61,5 +64,8 @@ testSets.forEach(function (testSet) {

describe(testSet.description, function() {
var validate, fullValidate;
// it(testSet.description, function() {
var validate = ajv.compile(testSet.schema);
var fullValidate = fullAjv.compile(testSet.schema);
before(function() {
validate = ajv.compile(testSet.schema);
fullValidate = fullAjv.compile(testSet.schema);
});

@@ -94,5 +100,7 @@ testSet.tests.forEach(function (test) {

return files.map(function (file) {
var optional = /optional\/\w+\.json/.test(file) ? 'optional/' : '';
return { path: file, name: optional + path.basename(file, '.json') };
var match = file.match(/(\w+\/)\w+\.json/)
var folder = match ? match[1] : '';
if (folder == 'draft4/') folder = '';
return { path: file, name: folder + path.basename(file, '.json') };
});
}
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