Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonschema

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonschema - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

32

lib/attribute.js

@@ -7,6 +7,22 @@ 'use strict';

attribute.informativeProperties = ['id', 'default', 'description', 'title'];
attribute.argumentProperties = ['exclusiveMinimum', 'exclusiveMaximum', 'items', 'additionalItems', 'properties', 'additionalProperties', 'patternProperties', 'extends'];
attribute.ignoreProperties = [].concat(attribute.informativeProperties, attribute.argumentProperties);
attribute.ignoreProperties = {
// informativeProperties
'id': true,
'default': true,
'description': true,
'title': true,
// argumentProperties
'exclusiveMinimum': true,
'exclusiveMaximum': true,
'items': true,
'additionalItems': true,
'properties': true,
'additionalProperties': true,
'patternProperties': true,
'extends': true
};
/**
* @name validators
*/
var validators = attribute.validators = {};

@@ -268,4 +284,4 @@

function testArrays(v, i, a) {
var j, len;
for (j = i + 1, len = a.length; j < len; j++) {
var j, len = a.length;
for (j = i + 1, len; j < len; j++) {
if (helpers.deepCompareStrict(v, a[j])) {

@@ -318,4 +334,4 @@ return false;

if (dep instanceof Array) {
var i, len;
for (i = 0, len = dep.length; i < len; i++) {
var i, len = dep.length;
for (i = 0, len; i < len; i++) {
if (instance[dep[i]] === undefined) {

@@ -337,3 +353,3 @@ return " property " + dep[i] + " not found, required by " + propPath;

/**
* Validates whether the instance value is one of the enumerated values, if the instance is an array.
* Validates whether the instance value is one of the enumerated values.
*

@@ -340,0 +356,0 @@ * @param instance

@@ -130,4 +130,6 @@ 'use strict';

var keys = Object.keys(schema);
keys.forEach(function (key) {
if (skipAttributes.indexOf(key) < 0 && attribute.ignoreProperties.indexOf(key) < 0) {
var key;
for (var i = 0, len = keys.length; i < len; i++ ) {
key = keys[i];
if (!attribute.ignoreProperties[key] && skipAttributes.indexOf(key) < 0) {
var validatorErr;

@@ -145,3 +147,3 @@ var validator = attribute.validators[key];

}
});
}
return errors;

@@ -179,19 +181,21 @@ };

var lookedAtPatternProperties = [];
var lookedAtPatternProperties = {};
var patternProperties = schema.patternProperties || {};
var pattern;
for (pattern in patternProperties) {
if (patternProperties.hasOwnProperty(pattern)) {
var expr = new RegExp(pattern);
for (property in instance) {
if (instance.hasOwnProperty(property)) {
if (!expr.test(property)) {
continue;
if (schema.patternProperties) {
var patternProperties = schema.patternProperties || {};
var pattern;
for (pattern in patternProperties) {
if (patternProperties.hasOwnProperty(pattern)) {
var expr = new RegExp(pattern);
for (property in instance) {
if (instance.hasOwnProperty(property)) {
if (!expr.test(property)) {
continue;
}
lookedAtPatternProperties[property] = true;
errs = this.validateSchema(instance[property], schema.patternProperties[pattern], options, propertyName + helpers.makeSuffix(property));
if (errs && errs.length) {
errors = errors.concat(errs);
}
}
lookedAtPatternProperties.push(property);
errs = this.validateSchema(instance[property], schema.patternProperties[pattern], options, propertyName + helpers.makeSuffix(property));
if (errs && errs.length) {
errors = errors.concat(errs);
}
}

@@ -206,3 +210,3 @@ }

if (instance.hasOwnProperty(property)) {
if (properties[property] !== undefined || lookedAtPatternProperties.indexOf(property) >= 0) {
if (properties[property] !== undefined || lookedAtPatternProperties[property]) {
continue;

@@ -209,0 +213,0 @@ }

{
"author": "Tom de Grunt <tom@degrunt.nl>",
"name": "jsonschema",
"version": "0.3.1",
"version": "0.3.2",
"dependencies": {

@@ -6,0 +6,0 @@ },

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