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

@allbin/entity-logic

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allbin/entity-logic - npm Package Compare versions

Comparing version 0.6.4 to 0.7.0

38

lib/index.js

@@ -313,5 +313,41 @@ "use strict";

}
var invalid = false;
var prev_val = prev_properties[p];
var prop_val = properties[p];
if (prev_val !== prop_val) {
switch (schema_prop.type) {
case 'array:number':
case 'array:string': {
var prev_is_array = Array.isArray(prev_val);
var prop_is_array = Array.isArray(prop_val);
if (prev_is_array !== prop_is_array) {
invalid = true;
}
if (!!prev_val !== !!prop_val) {
invalid = true;
}
if (Array.isArray(prev_val) && Array.isArray(prop_val)) {
if (prev_val.length !== prop_val.length) {
invalid = true;
}
for (var i = 0; i < prev_val.length; i++) {
if (prev_val[i] !== prop_val[i]) {
invalid = true;
}
}
}
break;
}
case 'boolean':
case 'number':
case 'string':
case 'date':
case 'photo':
case 'location': {
if (prev_val !== prop_val) {
invalid = true;
}
break;
}
}
if (invalid) {
throw new Error("Properties include modification to readonly property " + p);

@@ -318,0 +354,0 @@ }

@@ -74,2 +74,12 @@ "use strict";

},
{
key: 'inventory.10',
type: 'string',
name: 'string-readonly',
},
{
key: 'inventory.11',
type: 'array:string',
name: 'arraystring-readonly',
},
],

@@ -1175,3 +1185,3 @@ };

});
it('correctly validates modifiable properties', function () {
it('correctly validates modifiable single properties (pos)', function () {
var prev_props = {

@@ -1188,2 +1198,38 @@ 'inventory.3': 'something',

});
it('correctly validates modifiable single properties (neg)', function () {
var prev_props = {
'inventory.10': 'test',
};
var props = {
'inventory.10': 'test2',
};
var logic = (0, index_1.EntityLogic)(schema);
expect(function () {
return logic.validatePropertiesModifiable(prev_props, props);
}).toThrow();
});
it('correctly validates modifiable array properties (pos)', function () {
var prev_props = {
'inventory.11': ['test', 'test2'],
};
var props = {
'inventory.11': ['test', 'test2'],
};
var logic = (0, index_1.EntityLogic)(schema);
expect(function () {
return logic.validatePropertiesModifiable(prev_props, props);
}).not.toThrow();
});
it('correctly validates modifiable array properties (neg)', function () {
var prev_props = {
'inventory.11': ['test', 'test2'],
};
var props = {
'inventory.11': ['test2', 'test'],
};
var logic = (0, index_1.EntityLogic)(schema);
expect(function () {
return logic.validatePropertiesModifiable(prev_props, props);
}).toThrow();
});
});

2

package.json
{
"name": "@allbin/entity-logic",
"version": "0.6.4",
"version": "0.7.0",
"description": "Logic solver for mobilix filters",

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

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