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

@hyperjump/json-schema

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperjump/json-schema - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

10

lib/keywords.js

@@ -8,11 +8,3 @@ import metaData from "./keywords/meta-data.js";

export const addKeyword = (keywordHandler) => {
_keywords[keywordHandler.id] = {
collectEvaluatedItems: (keywordValue, instance, ast, dynamicAnchors, isTop) => {
return keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors, isTop) && new Set();
},
collectEvaluatedProperties: (keywordValue, instance, ast, dynamicAnchors, isTop) => {
return keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors, isTop) && [];
},
...keywordHandler
};
_keywords[keywordHandler.id] = keywordHandler;
};

@@ -19,0 +11,0 @@

52

lib/keywords/validation.js

@@ -92,2 +92,3 @@ import * as Pact from "@hyperjump/pact";

const emptyPropertyNames = [];
const collectEvaluatedProperties = (url, instance, ast, dynamicAnchors, isTop = false) => {

@@ -100,10 +101,24 @@ const nodes = ast[url][2];

return nodes
.filter(([keywordId]) => !isTop || keywordId !== "https://json-schema.org/keyword/unevaluatedProperties")
.reduce((acc, [keywordId, , keywordValue]) => {
const propertyNames = acc && getKeyword(keywordId).collectEvaluatedProperties(keywordValue, instance, ast, dynamicAnchors);
return propertyNames !== false && [...acc, ...propertyNames];
}, []);
const accumulatedPropertyNames = [];
for (const [keywordId, , keywordValue] of nodes) {
if (isTop && keywordId === "https://json-schema.org/keyword/unevaluatedProperties") {
continue;
}
const keywordHandler = getKeyword(keywordId);
const propertyNames = "collectEvaluatedProperties" in keywordHandler
? keywordHandler.collectEvaluatedProperties(keywordValue, instance, ast, dynamicAnchors, isTop)
: keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors, isTop) && emptyPropertyNames;
if (propertyNames === false) {
return false;
}
Array.prototype.push.apply(accumulatedPropertyNames, propertyNames);
}
return accumulatedPropertyNames;
};
const emptyItemIndexes = new Set();
const collectEvaluatedItems = (url, instance, ast, dynamicAnchors, isTop = false) => {

@@ -116,10 +131,23 @@ const nodes = ast[url][2];

return nodes
.filter(([keywordId]) => !isTop || keywordId !== "https://json-schema.org/keyword/unevaluatedItems")
.reduce((acc, [keywordId, , keywordValue]) => {
const itemIndexes = acc !== false && getKeyword(keywordId).collectEvaluatedItems(keywordValue, instance, ast, dynamicAnchors);
return itemIndexes !== false && new Set([...acc, ...itemIndexes]);
}, new Set());
const accumulatedItemIndexes = new Set();
for (const [keywordId, , keywordValue] of nodes) {
if (isTop && keywordId === "https://json-schema.org/keyword/unevaluatedItems") {
continue;
}
const keywordHandler = getKeyword(keywordId);
const itemIndexes = "collectEvaluatedItems" in keywordHandler
? keywordHandler.collectEvaluatedItems(keywordValue, instance, ast, dynamicAnchors, isTop)
: keywordHandler.interpret(keywordValue, instance, ast, dynamicAnchors, isTop) && emptyItemIndexes;
if (itemIndexes === false) {
return false;
}
itemIndexes.forEach(Set.prototype.add.bind(accumulatedItemIndexes));
}
return accumulatedItemIndexes;
};
export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems };
{
"name": "@hyperjump/json-schema",
"version": "1.2.2",
"version": "1.2.3",
"description": "A JSON Schema validator with support for custom keywords, vocabularies, and dialects",

@@ -74,4 +74,4 @@ "type": "module",

"engines": {
"node": "^18.0.0"
"node": ">=18.0.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