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

jsonpolice

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonpolice - npm Package Compare versions

Comparing version 8.0.3 to 8.0.4

1

dist/schema.d.ts

@@ -8,2 +8,3 @@ import { SchemaError } from './errors';

validate(data: any, opts?: ValidationOptions, path?: string): Promise<any>;
protected validateSpec(scope: string, data: any, spec: any, path: string, opts: ValidationOptions): any;
protected rootValidator(data: any, spec: any, path: string, opts: ValidationOptions): any;

@@ -10,0 +11,0 @@ protected typeValidator(data: any, spec: any, path: string, opts: ValidationOptions): any;

53

dist/schema.js

@@ -48,4 +48,15 @@ "use strict";

const spec = await this.spec();
return this.rootValidator(data, spec, path, opts);
return this.validateSpec(Schema.scope(spec), data, spec, path, opts);
}
validateSpec(scope, data, spec, path, opts) {
if (spec === true) {
return true;
}
else if (spec === false) {
throw new errors_1.ValidationError(path, scope, 'false');
}
else {
return this.rootValidator(data, spec, path, opts);
}
}
rootValidator(data, spec, path, opts) {

@@ -55,10 +66,2 @@ if (typeof data === 'undefined' && !opts.doNotAnnotate && opts.setDefault) {

}
if (typeof spec === 'boolean') {
if (spec) {
return spec;
}
else {
throw new errors_1.ValidationError(path, Schema.scope(spec), 'false');
}
}
let out = data;

@@ -245,3 +248,3 @@ const toAnnotate = [];

try {
data[i] = this.rootValidator(data[i], spec.items[i], `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.items[i], `${path}/${i}`, opts);
}

@@ -257,3 +260,3 @@ catch (err) {

try {
data[i] = this.rootValidator(data[i], spec.items, `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.items, `${path}/${i}`, opts);
}

@@ -277,3 +280,3 @@ catch (err) {

try {
data[i] = this.rootValidator(data[i], spec.additionalItems, `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.additionalItems, `${path}/${i}`, opts);
}

@@ -329,3 +332,3 @@ catch (err) {

try {
data[i] = this.rootValidator(data[i], spec.contains, `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.contains, `${path}/${i}`, opts);
found = true;

@@ -392,3 +395,3 @@ }

else {
data[i] = this.rootValidator(data[i], spec.properties[i], `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.properties[i], `${path}/${i}`, opts);
}

@@ -427,3 +430,3 @@ }

else {
data[i] = this.rootValidator(data[i], spec.patternProperties[p], `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.patternProperties[p], `${path}/${i}`, opts);
}

@@ -453,3 +456,3 @@ }

else {
data[i] = this.rootValidator(data[i], spec.additionalProperties, `${path}/${i}`, opts);
data[i] = this.validateSpec(Schema.scope(spec), data[i], spec.additionalProperties, `${path}/${i}`, opts);
}

@@ -493,3 +496,3 @@ }

try {
data = this.rootValidator(data, spec.dependencies[i], `${path}/dependencies/${i}`, opts);
data = this.validateSpec(Schema.scope(spec), data, spec.dependencies[i], `${path}/dependencies/${i}`, opts);
}

@@ -514,3 +517,3 @@ catch (err) {

// TODO should we change the key in data to reflect the result?
this.rootValidator(i, spec.propertyNames, `${path}/${i}#`, opts);
this.validateSpec(Schema.scope(spec), i, spec.propertyNames, `${path}/${i}#`, opts);
}

@@ -529,7 +532,7 @@ catch (err) {

try {
data = this.rootValidator(data, spec.if, path, opts);
data = this.validateSpec(Schema.scope(spec), data, spec.if, path, opts);
}
catch (err) {
if (spec.else) {
data = this.rootValidator(data, spec.else, path, opts);
data = this.validateSpec(Schema.scope(spec), data, spec.else, path, opts);
}

@@ -539,3 +542,3 @@ return data;

if (spec.then) {
data = this.rootValidator(data, spec.then, path, opts);
data = this.validateSpec(Schema.scope(spec), data, spec.then, path, opts);
}

@@ -551,3 +554,3 @@ return data;

try {
data = this.rootValidator(data, i, path, opts);
data = this.validateSpec(Schema.scope(spec), data, i, path, opts);
}

@@ -570,3 +573,3 @@ catch (err) {

try {
data = this.rootValidator(data, i, path, opts);
data = this.validateSpec(Schema.scope(spec), data, i, path, opts);
found = true;

@@ -588,3 +591,3 @@ }

try {
const newData = this.rootValidator(data, i, path, opts);
const newData = this.validateSpec(Schema.scope(spec), data, i, path, opts);
if (++found === 1) {

@@ -603,3 +606,3 @@ data = newData;

try {
this.rootValidator(data, spec.not, path, Object.assign({}, opts, { doNotAnnotate: true }));
this.validateSpec(Schema.scope(spec), data, spec.not, path, Object.assign({}, opts, { doNotAnnotate: true }));
}

@@ -606,0 +609,0 @@ catch (err) {

{
"name": "jsonpolice",
"version": "8.0.3",
"version": "8.0.4",
"description": "JSON Schema parser and validator",

@@ -83,5 +83,5 @@ "main": "dist/index.js",

"dependencies": {
"jsonref": "^5.1.1",
"jsonref": "^5.1.2",
"lodash": "^4.17.11"
}
}
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