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

archetype-js

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

archetype-js - npm Package Compare versions

Comparing version

to
0.5.1

2

package.json
{
"name": "archetype-js",
"version": "0.5.0",
"version": "0.5.1",
"author": "Valeri Karpov <val@boosterfuels.com>",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -34,2 +34,3 @@ 'use strict';

projection = _.cloneDeep(projection);
projection.$hasExclusiveChild = {};
let inclusive = null;

@@ -44,3 +45,3 @@ for (const key of Object.keys(projection)) {

}
markSubpaths(projection, key, projection[key]);
markSubpaths(projection.$hasExclusiveChild, key, projection[key]);
inclusive = false;

@@ -59,2 +60,3 @@ } else {

projection.$inclusive = inclusive;
return projection;

@@ -162,2 +164,3 @@ }

if (!schema._paths[newPath] || shouldSkipPath(projection, newPath)) {
debug('delete', key, shouldSkipPath(projection, newPath));
delete obj[key];

@@ -164,0 +167,0 @@ return;

@@ -7,4 +7,12 @@ 'use strict';

} else {
return projection[path] == null;
const parts = path.split('.');
let cur = parts[0];
for (let i = 0; i < parts.length - 1; ++i) {
if (projection[cur] != null) {
return false;
}
cur += '.' + parts[i + 1];
}
return projection[path] == null && projection.$hasExclusiveChild[path] == null;
}
}

@@ -622,2 +622,25 @@ 'use strict';

});
it('required underneath array', function() {
const Test = new Archetype({
products: [{ name: { $type: 'string', $required: true } }]
}).compile('Test');
assert.throws(function() {
new Test({ products: [{ name: null }] });
}, /required/);
});
it('object array under projection', function() {
const Test = new Archetype({
name: 'string',
arr: {
$type: [{ el: { $type: 'string' } }],
$required: true
}
}).compile('Test');
assert.deepEqual(new Test({ name: '1', arr: [{ el: '2' }]}, { arr: 1 }), {
arr: [{ el: '2' }]
});
});
});

@@ -624,0 +647,0 @@