New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@luvio/jsonschema-validate

Package Overview
Dependencies
Maintainers
0
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luvio/jsonschema-validate - npm Package Compare versions

Comparing version 5.11.0 to 5.12.0

29

dist/jsonschema-validate.js

@@ -44,2 +44,5 @@ /**

}
else if ('not' in schema) {
validateNot(data, schema, path);
}
else if (schema.type === 'object') {

@@ -87,12 +90,24 @@ if (dataType !== 'object') {

}
function validateNot(data, schema, path) {
try {
validateJsonSchema(data, schema.not, path);
}
catch (e) {
if (e instanceof JsonSchemaViolationError) {
// Failed validation of the not schema means it is valid
return;
}
throw e;
}
throw new JsonSchemaViolationError(`Data at ${path} validated against the schema of a not clause.`);
}
function validateObject(data, schema, path) {
const schemaKeys = Object.keys(schema.properties);
const requiredKeys = new Set(schema.required);
if (!schema.additionalProperties) {
const schemaKeySet = new Set(schemaKeys);
const additionalProperties = Object.keys(data).filter((key) => !schemaKeySet.has(key));
if (additionalProperties.length > 0) {
throw new AdditionalPropertiesError(`Object at path '${path}' contains unallowed additionalProperties: ${additionalProperties}.`);
const schemaKeySet = new Set(schemaKeys);
Object.keys(data).forEach((key) => {
if (!schemaKeySet.has(key)) {
validateJsonSchema(data[key], schema.additionalProperties, `${path}.additionalProperties[${key}]`);
}
}
});
for (let i = 0, length = schemaKeys.length; i < length; i++) {

@@ -151,3 +166,3 @@ const key = schemaKeys[i];

export { AdditionalPropertiesError, IncorrectTypeError, JsonSchemaViolationError, MaxItemsViolationError, MinItemsViolationError, MissingRequiredPropertyError, assertIsValid, validateAllOf, validateAnyOf, validateArray, validateJsonSchema, validateObject, validateScalar };
export { AdditionalPropertiesError, IncorrectTypeError, JsonSchemaViolationError, MaxItemsViolationError, MinItemsViolationError, MissingRequiredPropertyError, assertIsValid, validateAllOf, validateAnyOf, validateArray, validateJsonSchema, validateNot, validateObject, validateScalar };
//# sourceMappingURL=jsonschema-validate.js.map

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

export type JSONSchema = ObjectType | ArrayType | ScalarType | AnyOf | AllOf | boolean;
export type JSONSchema = ObjectType | ArrayType | ScalarType | AnyOf | AllOf | Not | boolean;
export type ObjectType = {

@@ -6,3 +6,3 @@ type: 'object';

required: string[];
additionalProperties: boolean;
additionalProperties: JSONSchema;
};

@@ -21,2 +21,5 @@ export type ArrayType = {

};
export type Not = {
not: JSONSchema;
};
type ScalarType = IntegerType | NumberType | StringType | BooleanType | NullType;

@@ -61,5 +64,6 @@ export type IntegerType = {

export declare function validateAllOf(data: unknown, schema: AllOf, path: string): void;
export declare function validateObject(data: object, schema: ObjectType, path: string): void;
export declare function validateNot(data: unknown, schema: Not, path: string): void;
export declare function validateObject(data: Record<string, unknown>, schema: ObjectType, path: string): void;
export declare function validateArray(data: Array<unknown>, schema: ArrayType, path: string): void;
export declare function validateScalar(data: number | string | boolean | null, schema: ScalarType, path: string): void;
export {};
{
"name": "@luvio/jsonschema-validate",
"version": "5.11.0",
"version": "5.12.0",
"private": false,

@@ -5,0 +5,0 @@ "description": "Luvio Next JSON Schema Validation",

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