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.4 to 0.5.5

spec/remotes/bar.json

4

lib/compile/resolve.js

@@ -39,7 +39,7 @@ 'use strict';

if (refPath !== baseId) {
var refVal = this._refs[refPath];
var id = normalizeId(refPath);
var refVal = this._refs[id];
if (typeof refVal == 'string') refVal = this._refs[refVal];
if (typeof refVal == 'function') util.copy(refVal, root);
else {
var id = normalizeId(refPath);
var refVal = this._schemas[id];

@@ -46,0 +46,0 @@ if (typeof refVal == 'function') {

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

if ($refVal === undefined) {
var $message = 'can\'t resolve reference ' + $schema;
var $message = 'can\'t resolve reference ' + $schema + ' from id ' + it.baseId;
if (it.opts.missingRefs == 'fail') {

@@ -37,0 +37,0 @@ console.log($message);

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

$data = 'data';
it.rootId = it.baseId = it.resolve.fullPath(it.schema.id);
it.rootId = it.baseId = it.resolve.fullPath(it.root.schema.id);
delete it.isTop;

@@ -12,0 +12,0 @@ it.wasTop = true;

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

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

@@ -7,6 +7,6 @@ # ajv - Another JSON Schema Validator

[![Build Status](https://travis-ci.org/epoberezkin/ajv.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv)
[![npm version](https://badge.fury.io/js/ajv.svg)](http://badge.fury.io/js/ajv)
## JSON Schema standard

@@ -156,4 +156,5 @@

- _formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.
- _schemas_: an array or object of schemas that will be added to the instance. If the order is important, pass array. In this case schemas must have IDs in them. Otherwise the object can be passed - `addSchema(value, key)` will be called for each schema in this object.
- _meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default).
- _validateSchema_: validate added/compiled schemas against meta-schema (true by default). `$schema` property in the schema can either be absent (draft-4 meta-schema will be used) or can be a reference to any previously added schema. If the validation fails, the exception is thrown. Pass "log" in this option to log error instead of throwing exception.
- _validateSchema_: validate added/compiled schemas against meta-schema (true by default). `$schema` property in the schema can either be absent (draft-4 meta-schema will be used) or can be a reference to any previously added schema. If the validation fails, the exception is thrown. Pass "log" in this option to log error instead of throwing exception. Pass `false` to skip schema validation.
- _missingRefs_: by default if the reference cannot be resolved during compilation the exception is thrown. Pass 'ignore' to log error during compilation and pass validation. Pass 'fail' to log error and successfully compile schema but fail validation if this rule is checked.

@@ -160,0 +161,0 @@ - _uniqueItems_: validate `uniqueItems` keyword (true by default).

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

// 'optional/format', 'optional/bignum',
// 'ref',
// 'refRemote',
// 'definitions',
// 'schemas/complex',
// 'schemas/basic'
// 'schemas/advanced'
// 'issues/12_restoring_root_after_resolve'
// 'ref', 'refRemote', 'definitions',
// 'schemas/complex', 'schemas/basic', 'schemas/advanced',
// ];

@@ -39,7 +34,16 @@

var remoteRefs = {
// for JSON-Schema-Test-Suite
'http://localhost:1234/integer.json': require('./JSON-Schema-Test-Suite/remotes/integer.json'),
'http://localhost:1234/subSchemas.json': require('./JSON-Schema-Test-Suite/remotes/subSchemas.json'),
'http://localhost:1234/folder/folderInteger.json': require('./JSON-Schema-Test-Suite/remotes/folder/folderInteger.json')
'http://localhost:1234/folder/folderInteger.json': require('./JSON-Schema-Test-Suite/remotes/folder/folderInteger.json'),
// for tests
'http://localhost:1234/name.json': require('./remotes/name.json')
};
var remoteRefsWithIds = [ // order is important
require('./remotes/bar.json'),
require('./remotes/foo.json'),
require('./remotes/buu.json'),
];
for (var id in remoteRefs) {

@@ -50,3 +54,6 @@ ajv.addSchema(remoteRefs[id], id);

ajv.addSchema(remoteRefsWithIds);
fullAjv.addSchema(remoteRefsWithIds);
describe('Schema validation tests', function() {

@@ -71,3 +78,3 @@ addTests('JSON-Schema tests draft4', './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json');

// if (testSet.description != 'change resolution scope') return;
(testSet.skip ? describe.skip : describe)(testSet.description, function() {
skipOrOnly(testSet, describe)(testSet.description, function() {
var validate, fullValidate;

@@ -83,3 +90,3 @@ // it(testSet.description, function() {

// if (test.description != 'valid number') return;
(test.skip ? it.skip : it)(test.description, function() {
skipOrOnly(test, it)(test.description, function() {
var valid = validate(test.data);

@@ -106,2 +113,7 @@ // if (valid !== test.valid) console.log('result', valid, test.valid, validate.errors);

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

@@ -108,0 +120,0 @@ var files = glob.sync(testsPath, { cwd: __dirname });

@@ -52,3 +52,90 @@ [

]
},
{
"description": "root ref in ref with anyOf (#2)",
"schema": {
"definitions": {
"orNull": {
"anyOf": [
{ "type": "null" },
{ "$ref": "#" }
]
}
},
"type": "object",
"properties": {
"name": { "type": "string" },
"parent": { "$ref": "#/definitions/orNull" }
}
},
"tests": [
{
"description": "null parent is valid",
"data": {
"name": "foo",
"parent": null
},
"valid": true
},
{
"skip": false,
"description": "object parent is valid",
"data": {
"name": "foo",
"parent": {
"name": "bar",
"parent": null
}
},
"valid": true
},
{
"description": "object parent is valid",
"data": {
"name": "foo",
"parent": {
"name": "bar",
"parent": {
"name": "baz",
"parent": null
}
}
},
"valid": true
},
{
"description": "string parent is invalid",
"data": {
"name": "foo",
"parent": "buu"
},
"valid": false
},
{
"description": "string subparent is invalid",
"data": {
"name": "foo",
"parent": {
"name": "bar",
"parent": "baz"
}
},
"valid": false
},
{
"description": "string sub-subparent is invalid",
"data": {
"name": "foo",
"parent": {
"name": "bar",
"parent": {
"name": "baz",
"parent": "quux"
}
}
},
"valid": false
}
]
}
]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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