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

mastercheck

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mastercheck - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

14

lib/mastercheck.js

@@ -7,2 +7,3 @@ /**

*/
var _ = require('lodash');
var async = require('async');

@@ -15,2 +16,4 @@

this._idAttribute = '_id';
// key map. used to check `existIn`.
this._keyMap = {};
}

@@ -25,5 +28,6 @@

*/
MasterCheck.prototype.setup = function(formatData, idAttribute) {
MasterCheck.prototype.setup = function(formatData, idAttribute, keyMap) {
this._formatData = formatData || this._formatData;
this._idAttribute = idAttribute || this._idAttribute;
_.extend(this._keyMap, keyMap || {});
};

@@ -86,2 +90,3 @@

* select: [ 'apple_a1', 'apple_b2', 'apple_c3' ], // Select match check. Default do not check.
* existIn: 'Item', // exist in keyMap check. Default do not check.
* };

@@ -114,2 +119,5 @@ */

}
if (_option.hasOwnProperty('existIn') && this._keyMap.hasOwnProperty(_option.existIn) && !~this._keyMap[_option.existIn].indexOf(data)) {
return data + ' should be exist in ' + _option.existIn;
}
};

@@ -241,3 +249,5 @@ },

}
return new Format(option, format);
var f = new Format(option, format);
f._keyMap = this._keyMap;
return f;
};

@@ -244,0 +254,0 @@

63

package.json
{
"name": "mastercheck",
"version": "0.2.10",
"description": "mastercheck",
"main": "index.js",
"scripts": {
"test": "mocha -r should -R spec --recursive test",
"jshint": "jshint lib/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/yuhei-a/mastercheck.git"
},
"keywords": [
"mastercheck",
"master",
"data",
"check"
],
"author": "Yuhei Aihara",
"license": "MIT",
"bugs": {
"url": "https://github.com/yuhei-a/mastercheck/issues"
},
"dependencies": {
"async": "~0.2.10"
},
"devDependencies": {
"should": "~3.1.3",
"mocha": "~1.17.1",
"jshint": "~2.4.4"
}
"name": "mastercheck",
"version": "0.2.11",
"description": "mastercheck",
"main": "index.js",
"scripts": {
"test": "mocha -r should -R spec --recursive test",
"jshint": "jshint lib/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/yuhei-a/mastercheck.git"
},
"keywords": [
"mastercheck",
"master",
"data",
"check"
],
"author": "Yuhei Aihara",
"license": "MIT",
"bugs": {
"url": "https://github.com/yuhei-a/mastercheck/issues"
},
"dependencies": {
"async": "~0.2.10",
"lodash": "~2.4.1"
},
"devDependencies": {
"should": "~3.1.3",
"mocha": "~1.17.1",
"jshint": "~2.4.4"
}
}

@@ -12,3 +12,3 @@ var should = require('should');

obj: {
code: masterCheck.format('String', { minLength: 1, maxLength: 10 }),
code: masterCheck.format('String', { minLength: 1, maxLength: 10, existIn: 'B' }),
type: masterCheck.format('String', { select: [ 'Dog', 'Cat' ] }),

@@ -34,3 +34,3 @@ bool: masterCheck.format('Boolean', function(parents) {

};
masterCheck.setup(format);
masterCheck.setup(format, '_id', { B: [ 'test1_1', 'test2_1' ] });
done();

@@ -243,2 +243,27 @@ });

});
it('Exist in keyMap check test.', function(done) {
var dataList = [
{
_id: 'test1',
obj: {
code: 'test1_1'
},
arr: []
},
{
_id: 'test2',
obj: {
code: 'test2_2'
},
arr: []
}
];
masterCheck.check('A', dataList, function(err, result) {
should.not.exist(err);
should.exist(result);
result.should.eql({ test2: [ { key: 'obj.code', value: 'test2_2', message: 'test2_2 should be exist in B' } ] });
done();
});
});
});

@@ -245,0 +270,0 @@

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