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

@humanwhocodes/object-schema

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humanwhocodes/object-schema - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json
{
"name": "@humanwhocodes/object-schema",
"version": "1.1.0",
"version": "1.1.1",
"description": "An object schema merger/validator",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -115,8 +115,12 @@ /**

return objects.reduce((result, object) => {
this.validate(object);
for (const [key, strategy] of this[strategies]) {
try {
const value = strategy.merge.call(this, result[key], object[key]);
if (value !== undefined) {
result[key] = value;
if (key in result || key in object) {
const value = strategy.merge.call(this, result[key], object[key]);
if (value !== undefined) {
result[key] = value;
}
}

@@ -160,3 +164,3 @@ } catch (ex) {

try {
strategy.validate.call(strategy, object);
strategy.validate.call(strategy, object[key]);
} catch (ex) {

@@ -163,0 +167,0 @@ ex.message = `Key "${key}": ` + ex.message;

@@ -105,2 +105,19 @@ /**

it("should not call the merge() strategy when both objects don't contain the key", () => {
let called = false;
schema = new ObjectSchema({
foo: {
merge() {
called = true;
},
validate() {}
}
});
schema.merge({}, {});
assert.isFalse(called, "The merge() strategy should not have been called.");
});
it("should omit returning the key when the merge() strategy returns undefined", () => {

@@ -190,2 +207,17 @@ schema = new ObjectSchema({

it("should pass the property value into validate() when key is found", () => {
schema = new ObjectSchema({
foo: {
merge() {
return "bar";
},
validate(value) {
assert.isTrue(value);
}
}
});
schema.validate({ foo: true });
});
it("should not throw an error when expected keys are found", () => {

@@ -192,0 +224,0 @@ schema = new ObjectSchema({

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