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

@composer-js/core

Package Overview
Dependencies
Maintainers
0
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@composer-js/core - npm Package Compare versions

Comparing version 6.0.0-rc.14 to 6.0.0-rc.16

1

dist/lib/index.js

@@ -26,2 +26,3 @@ "use strict";

__exportStar(require("./ObjectFactory"), exports);
__exportStar(require("./ObjectUtils"), exports);
__exportStar(require("./OASUtils"), exports);

@@ -28,0 +29,0 @@ __exportStar(require("./StringUtils"), exports);

37

dist/lib/ObjectUtils.js

@@ -15,25 +15,28 @@ "use strict";

/**
* Performs validation of the given object. Validation is performed by scanning the object class for properties
* Performs validation of the given object or array. Validation is performed by scanning the object class for properties
* decorated with `@Validator` and executing the provided validation function.
*
* @param obj The object to validate.
* @param obj The object or array of objects to validate.
* @param recurse Set to `true` to validate all child objects.
*/
static validate(obj, recurse) {
// Iterate through all properties of the object
for (const member of Object.getOwnPropertyNames(obj)) {
if (member === 'constructor')
continue;
const nullable = Reflect.getMetadata("cjs:nullable", obj, member);
if (!nullable && !obj[member]) {
throw new Error(`Property ${member} cannot be null.`);
const objs = Array.isArray(obj) ? obj : [obj];
for (const obj of objs) {
// Iterate through all properties of the object
for (const member of Object.getOwnPropertyNames(obj)) {
if (member === 'constructor')
continue;
const nullable = Reflect.getMetadata("cjs:nullable", obj, member);
if (!nullable && !obj[member]) {
throw new Error(`Property ${member} cannot be null.`);
}
const validator = Reflect.getMetadata("cjs:validator", obj, member);
if (validator && obj[member] && !validator(obj[member])) {
throw new Error(`Property ${member} is invalid.`);
}
// If recursion is requested validate the child object
if (recurse && typeof obj[member] === "object") {
ObjectUtils.validate(obj[member], recurse);
}
}
const validator = Reflect.getMetadata("cjs:validator", obj, member);
if (validator && obj[member] && !validator(obj[member])) {
throw new Error(`Property ${member} is invalid.`);
}
// If recursion is requested validate the child object
if (recurse && typeof obj[member] === "object") {
ObjectUtils.validate(obj[member], recurse);
}
}

@@ -40,0 +43,0 @@ }

@@ -10,2 +10,3 @@ export * from "./ApiError";

export * from "./ObjectFactory";
export * from "./ObjectUtils";
export * from "./OASUtils";

@@ -12,0 +13,0 @@ export * from "./StringUtils";

@@ -9,6 +9,6 @@ import "reflect-metadata";

/**
* Performs validation of the given object. Validation is performed by scanning the object class for properties
* Performs validation of the given object or array. Validation is performed by scanning the object class for properties
* decorated with `@Validator` and executing the provided validation function.
*
* @param obj The object to validate.
* @param obj The object or array of objects to validate.
* @param recurse Set to `true` to validate all child objects.

@@ -15,0 +15,0 @@ */

{
"name": "@composer-js/core",
"version": "6.0.0-rc.14",
"version": "6.0.0-rc.16",
"description": "A collection of common utilities and core functionality for composerjs applications.",

@@ -5,0 +5,0 @@ "repository": "https://gitlab.acceleratxr.com/composerjs/composer-core.git",

Sorry, the diff of this file is not supported yet

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