🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

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

to
0.5.6

2

bin/compile_dots.js

@@ -12,2 +12,4 @@ //compile doT templates to js functions

console.log('\n\nCompiling:')
files.forEach(function (f) {

@@ -14,0 +16,0 @@ var template = fs.readFileSync(path.join(__dirname, f));

10

lib/compile/index.js

@@ -22,2 +22,5 @@ 'use strict';

root = root || { schema: schema, refVal: refVal, refs: refs };
var rootRefs = root.refs;
var rootRefVal = root.refVal;
var formats = this._formats;

@@ -70,9 +73,8 @@

if (!isRoot) {
var rootRefId = root.refs[ref];
var rootRefId = rootRefs[ref];
if (rootRefId !== undefined)
return addLocalRef(ref, root.refVal[rootRefId]);
return addLocalRef(ref, rootRefVal[rootRefId]);
}
var v = resolve.call(self, compile, root, ref);
if (v)
return addLocalRef(ref, v);
if (v) return addLocalRef(ref, v);
}

@@ -79,0 +81,0 @@

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

} else {
out += ' if (! ' + ('root.refVal[0]') + '(' + ($data) + ', (dataPath || \'\') + ' + (it.errorPath) + ') ) { if (validate.errors === null) validate.errors = ' + ('root.refVal[0]') + '.errors; else validate.errors = validate.errors.concat(' + ('root.refVal[0]') + '.errors); errors = validate.errors.length; } ';
out += ' if (! ' + ('rootRefVal[0]') + '(' + ($data) + ', (dataPath || \'\') + ' + (it.errorPath) + ') ) { if (validate.errors === null) validate.errors = ' + ('rootRefVal[0]') + '.errors; else validate.errors = validate.errors.concat(' + ('rootRefVal[0]') + '.errors); errors = validate.errors.length; } ';
if ($breakOnError) {

@@ -45,3 +45,3 @@ out += ' else { ';

} else {
out += ' var err = { keyword: \'' + ('$ref') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'can\\\'t resolve reference ' + ($schema) + '\' ';
out += ' var err = { keyword: \'' + ('$ref') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'can\\\'t resolve reference ' + ($schema) + '\' ';
if (it.opts.verbose) {

@@ -48,0 +48,0 @@ out += ', schema: \'' + ($schema) + '\', data: ' + ($data);

@@ -35,3 +35,7 @@ 'use strict';

}
out += ' ' + ($closingBraces) + ' if (' + ($valid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (' + ($errs) + ') validate.errors.length = ' + ($errs) + '; else validate.errors = null; } ';
out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') { var err = { keyword: \'' + ('anyOf') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match some schema in anyOf\' ';
if (it.opts.verbose) {
out += ', schema: validate.schema' + ($schemaPath) + ', data: ' + ($data);
}
out += ' }; if (validate.errors === null) validate.errors = [err]; else validate.errors.push(err); errors++; } else { errors = ' + ($errs) + '; if (validate.errors !== null) { if (' + ($errs) + ') validate.errors.length = ' + ($errs) + '; else validate.errors = null; } ';
if (it.opts.allErrors) {

@@ -38,0 +42,0 @@ out += ' } ';

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

} else {
out += ' var err = { keyword: \'' + ('dependencies') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'';
out += ' var err = { keyword: \'' + ('dependencies') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'';
if ($deps.length == 1) {

@@ -59,0 +59,0 @@ out += 'property ' + ($deps[0]) + ' is';

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

} else {
out += ' var err = { keyword: \'' + ('enum') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be equal to one of values\' ';
out += ' var err = { keyword: \'' + ('enum') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be equal to one of values\' ';
if (it.opts.verbose) {

@@ -27,0 +27,0 @@ out += ', schema: validate.schema' + ($schemaPath) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('format') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match format ' + ($schema) + '\' ';
out += ' var err = { keyword: \'' + ('format') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match format ' + ($schema) + '\' ';
if (it.opts.verbose) {

@@ -34,0 +34,0 @@ out += ', schema: \'' + ($schema) + '\', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('additionalItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have more than ' + ($schema.length) + ' items\' ';
out += ' var err = { keyword: \'' + ('additionalItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have more than ' + ($schema.length) + ' items\' ';
if (it.opts.verbose) {

@@ -35,0 +35,0 @@ out += ', schema: false, data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('maximum') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ' + ($op) + ' ' + ($schema) + '\' ';
out += ' var err = { keyword: \'' + ('maximum') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ' + ($op) + ' ' + ($schema) + '\' ';
if (it.opts.verbose) {

@@ -29,0 +29,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('maxItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have more than ' + ($schema) + ' items\' ';
out += ' var err = { keyword: \'' + ('maxItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have more than ' + ($schema) + ' items\' ';
if (it.opts.verbose) {

@@ -26,0 +26,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('maxLength') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be longer than ' + ($schema) + ' characters\' ';
out += ' var err = { keyword: \'' + ('maxLength') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be longer than ' + ($schema) + ' characters\' ';
if (it.opts.verbose) {

@@ -32,0 +32,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('maxProperties') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have more than ' + ($schema) + ' properties\' ';
out += ' var err = { keyword: \'' + ('maxProperties') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have more than ' + ($schema) + ' properties\' ';
if (it.opts.verbose) {

@@ -26,0 +26,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('minimum') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ' + ($op) + ' ' + ($schema) + '\' ';
out += ' var err = { keyword: \'' + ('minimum') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ' + ($op) + ' ' + ($schema) + '\' ';
if (it.opts.verbose) {

@@ -29,0 +29,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('minItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have less than ' + ($schema) + ' items\' ';
out += ' var err = { keyword: \'' + ('minItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have less than ' + ($schema) + ' items\' ';
if (it.opts.verbose) {

@@ -26,0 +26,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('minLength') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be shorter than ' + ($schema) + ' characters\' ';
out += ' var err = { keyword: \'' + ('minLength') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be shorter than ' + ($schema) + ' characters\' ';
if (it.opts.verbose) {

@@ -32,0 +32,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('minProperties') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have less than ' + ($schema) + ' properties\' ';
out += ' var err = { keyword: \'' + ('minProperties') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT have less than ' + ($schema) + ' properties\' ';
if (it.opts.verbose) {

@@ -26,0 +26,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('multipleOf') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be multiple of ' + ($schema) + '\' ';
out += ' var err = { keyword: \'' + ('multipleOf') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be multiple of ' + ($schema) + '\' ';
if (it.opts.verbose) {

@@ -26,0 +26,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('not') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be valid\' ';
out += ' var err = { keyword: \'' + ('not') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be valid\' ';
if (it.opts.verbose) {

@@ -48,3 +48,3 @@ out += ', schema: validate.schema' + ($schemaPath) + ', data: ' + ($data);

} else {
out += ' var err = { keyword: \'' + ('not') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be valid\' ';
out += ' var err = { keyword: \'' + ('not') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should NOT be valid\' ';
if (it.opts.verbose) {

@@ -51,0 +51,0 @@ out += ', schema: validate.schema' + ($schemaPath) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('oneOf') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match exactly one schema in oneOf\' ';
out += ' var err = { keyword: \'' + ('oneOf') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match exactly one schema in oneOf\' ';
if (it.opts.verbose) {

@@ -50,0 +50,0 @@ out += ', schema: validate.schema' + ($schemaPath) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('pattern') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match pattern "' + ($schema) + '"\' ';
out += ' var err = { keyword: \'' + ('pattern') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should match pattern "' + ($schema) + '"\' ';
if (it.opts.verbose) {

@@ -27,0 +27,0 @@ out += ', schema: \'' + ($schema) + '\', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('additionalProperties') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'additional properties NOT allowed\' ';
out += ' var err = { keyword: \'' + ('additionalProperties') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'additional properties NOT allowed\' ';
if (it.opts.verbose) {

@@ -63,0 +63,0 @@ out += ', schema: false, data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('required') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'properties ' + ($schema.slice(0, 7).join(", "));
out += ' var err = { keyword: \'' + ('required') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'properties ' + ($schema.slice(0, 7).join(", "));
if ($schema.length > 7) {

@@ -69,3 +69,3 @@ out += '...';

} else {
out += ' var err = { keyword: \'' + ('required') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'properties ' + ($schema.slice(0, 7).join(", "));
out += ' var err = { keyword: \'' + ('required') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'properties ' + ($schema.slice(0, 7).join(", "));
if ($schema.length > 7) {

@@ -72,0 +72,0 @@ out += '...';

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

} else {
out += ' var err = { keyword: \'' + ('uniqueItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'items ## \' + j + \' and \' + i + \' are duplicate\' ';
out += ' var err = { keyword: \'' + ('uniqueItems') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'items ## \' + j + \' and \' + i + \' are duplicate\' ';
if (it.opts.verbose) {

@@ -27,0 +27,0 @@ out += ', schema: ' + ($schema) + ', data: ' + ($data);

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

} else {
out += ' var err = { keyword: \'' + ('type') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ';
out += ' var err = { keyword: \'' + ('type') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ';
if ($isArray) {

@@ -141,3 +141,3 @@ out += '' + ($typeSchema.join(","));

} else {
out += ' var err = { keyword: \'' + ('type') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ';
out += ' var err = { keyword: \'' + ('type') + '\', dataPath: (dataPath || \'\') + ' + (it.errorPath) + ', message: \'should be ';
if ($isArray) {

@@ -144,0 +144,0 @@ out += '' + ($typeSchema.join(","));

{
"name": "ajv",
"version": "0.5.5",
"version": "0.5.6",
"description": "Another JSON schema Validator",

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

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

var ONLY_FILES, SKIP_FILES;
// ONLY_FILES = [
ONLY_FILES = [
// 'type', 'not', 'allOf', 'anyOf', 'oneOf', 'enum',

@@ -19,3 +19,3 @@ // 'maximum', 'minimum', 'multipleOf', 'maxLength', 'minLength', 'pattern',

// 'schemas/complex', 'schemas/basic', 'schemas/advanced',
// ];
];

@@ -69,34 +69,31 @@ SKIP_FILES = [

files.forEach(function (file) {
var skip = (ONLY_FILES && ONLY_FILES.indexOf(file.name) == -1) ||
(SKIP_FILES && SKIP_FILES.indexOf(file.name) >= 0);
// if (skip) return;
var filter = {
skip: SKIP_FILES && SKIP_FILES.indexOf(file.name) >= 0,
only: ONLY_FILES && ONLY_FILES.indexOf(file.name) >= 0
}
(skip ? describe.skip : describe) (file.name, function() {
skipOrOnly(filter, describe)(file.name, function() {
var testSets = require(file.path);
testSets.forEach(function (testSet) {
// if (testSet.description != 'change resolution scope') return;
skipOrOnly(testSet, describe)(testSet.description, function() {
var validate, fullValidate;
// it(testSet.description, function() {
before(function() {
validate = ajv.compile(testSet.schema);
// console.log('validate', validate.toString());
fullValidate = fullAjv.compile(testSet.schema);
// fullValidate = fullAjv.compile(testSet.schema);
});
testSet.tests.forEach(function (test) {
// if (test.description != 'valid number') return;
skipOrOnly(test, it)(test.description, function() {
doTest(validate);
// doTest(fullValidate);
});
function doTest(validate) {
var valid = validate(test.data);
// if (valid !== test.valid) 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);
if (valid) assert(validate.errors === null);
else assert(validate.errors.length > 0);
var valid = fullValidate(test.data);
// console.log('full result', valid, fullValidate.errors);
assert.equal(valid, test.valid);
if (valid) assert(fullValidate.errors === null);
else assert(fullValidate.errors.length > 0);
});
}
});

@@ -111,4 +108,4 @@ });

function skipOrOnly(test, func) {
return test.only ? func.only : test.skip ? func.skip : func;
function skipOrOnly(filter, func) {
return filter.only ? func.only : filter.skip ? func.skip : func;
}

@@ -115,0 +112,0 @@

[
{
"skip": true,
"description": "root ref in remote ref (#13)",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet