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.4.4 to 1.4.5

2

bundle/index.js

@@ -95,3 +95,3 @@ import { v4 as uuid } from "uuid";

if (additionalProperties) {
additionalProperties.collectExternalIds = ([, , additionalProperties], externalIds, ast, dynamicAnchors) => {
additionalProperties.collectExternalIds = ([, additionalProperties], externalIds, ast, dynamicAnchors) => {
if (typeof additionalProperties === "string") {

@@ -98,0 +98,0 @@ Validation.collectExternalIds(additionalProperties, externalIds, ast, dynamicAnchors);

@@ -1,2 +0,2 @@

import { resolveIri, toAbsoluteIri, parseIriReference } from "@hyperjump/uri";
import { resolveIri, parseIriReference } from "@hyperjump/uri";
import * as JsonPointer from "@hyperjump/json-pointer";

@@ -3,0 +3,0 @@

@@ -10,14 +10,29 @@ import * as Schema from "../schema.js";

const compile = async (schema, ast, parentSchema) => {
const patterns = [];
const propertiesKeyword = getKeywordName(schema.dialectId, "https://json-schema.org/keyword/properties");
const propertiesSchema = await Schema.step(propertiesKeyword, parentSchema);
const propertyNames = Schema.typeOf(propertiesSchema, "object") ? Schema.keys(propertiesSchema) : [];
if (Schema.typeOf(propertiesSchema, "object")) {
for (const name of Schema.keys(propertiesSchema)) {
patterns.push(regexEscape(name));
}
}
const patternPropertiesKeyword = getKeywordName(schema.dialectId, "https://json-schema.org/keyword/patternProperties");
const patternProperties = await Schema.step(patternPropertiesKeyword, parentSchema);
const propertyNamePatterns = Schema.typeOf(patternProperties, "object") ? Schema.keys(patternProperties).map((pattern) => new RegExp(pattern)) : [];
if (Schema.typeOf(patternProperties, "object")) {
patterns.push(...Schema.keys(patternProperties));
}
return [propertyNames, propertyNamePatterns, await Validation.compile(schema, ast)];
return [
new RegExp(patterns.length > 0 ? patterns.join("|") : "(?!)", "u"),
await Validation.compile(schema, ast)
];
};
const interpret = ([propertyNames, propertyNamePatterns, additionalProperties], instance, ast, dynamicAnchors, quiet) => {
const regexEscape = (string) => string
.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&")
.replace(/-/g, "\\x2d");
const interpret = ([isDefinedProperty, additionalProperties], instance, ast, dynamicAnchors, quiet) => {
if (!Instance.typeOf(instance, "object")) {

@@ -28,7 +43,7 @@ return true;

return Instance.entries(instance)
.filter(([propertyName]) => !propertyNames.includes(propertyName) && !propertyNamePatterns.some((pattern) => pattern.test(propertyName)))
.filter(([propertyName]) => !isDefinedProperty.test(propertyName))
.every(([, property]) => Validation.interpret(additionalProperties, property, ast, dynamicAnchors, quiet));
};
const collectEvaluatedProperties = ([propertyNames, propertyNamePatterns, additionalProperties], instance, ast, dynamicAnchors) => {
const collectEvaluatedProperties = ([isDefinedProperty, additionalProperties], instance, ast, dynamicAnchors) => {
if (!Instance.typeOf(instance, "object")) {

@@ -40,3 +55,3 @@ return true;

for (const [propertyName, property] of Instance.entries(instance)) {
if (!propertyNames.includes(propertyName) && !propertyNamePatterns.some((pattern) => pattern.test(propertyName))) {
if (!isDefinedProperty.test(propertyName)) {
if (!Validation.interpret(additionalProperties, property, ast, dynamicAnchors, true)) {

@@ -43,0 +58,0 @@ return false;

{
"name": "@hyperjump/json-schema",
"version": "1.4.4",
"version": "1.4.5",
"description": "A JSON Schema validator with support for custom keywords, vocabularies, and dialects",

@@ -5,0 +5,0 @@ "type": "module",

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