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.13 to 0.2.14

34

lib/mastercheck.js

@@ -226,4 +226,7 @@ /**

* var option = {
* minLength: 0, // Minimum number of characters check. Default do not check.
* maxLength: 20, // Maximum number of characters check. Default do not check.
* match: /^apple_/, // String match check. Value to use for the String#match. Default do not check.
* select: [ 'apple_a1', 'apple_b2', 'apple_c3' ], // Select match check. Default do not check.
* existIn: [ 'Item' ], // exist in keyMap check. Default do not check.
* };

@@ -235,4 +238,7 @@ */

var _option = (typeof this.option === 'function' ? this.option(parents, data) : this.option) || {};
if (_option.hasOwnProperty('minLength') && _option.minLength > data.length) {
return data + ' length should be above ' + _option.minLength;
}
if (_option.hasOwnProperty('maxLength') && _option.maxLength < data.length) {
return data + ' length should be above ' + _option.maxLength;
return data + ' length should be below ' + _option.maxLength;
}

@@ -243,4 +249,22 @@ if (_option.hasOwnProperty('match') && !data.match(_option.match)) {

if (_option.hasOwnProperty('select') && !~_option.select.indexOf(data)) {
return data + ' should match ' + _option.select;
return data + ' should match ' + _option.select.join(' or ');
}
if (_option.hasOwnProperty('existIn')) {
if (Array.isArray(_option.existIn)) {
var has = false;
for (var i = 0; i < _option.existIn.length; i++) {
if (this._keyMap[_option.existIn[i]] && ~this._keyMap[_option.existIn[i]].indexOf(data)) {
has = true;
break;
}
}
if (!has) {
return data + ' should be exist in ' + _option.existIn;
}
} else {
if (!this._keyMap[_option.existIn] || !~this._keyMap[_option.existIn].indexOf(data)) {
return data + ' should be exist in ' + _option.existIn;
}
}
}
};

@@ -306,5 +330,7 @@ this.format = format;

}
_errs = this._check(_format.format, _master[_key], _parents);
var newFormat = {};
newFormat[_key] = _format.format;
_errs = this._check(newFormat, _master, parents);
for (i = 0; i < _errs.length; i++) {
errs.push({ key: key + '.' + _key + '.' + _errs[i].key, value: _errs[i].value, message: _errs[i].message });
errs.push({ key: key + '.' + _errs[i].key, value: _errs[i].value, message: _errs[i].message });
}

@@ -311,0 +337,0 @@ }

2

package.json
{
"name": "mastercheck",
"version": "0.2.13",
"version": "0.2.14",
"description": "mastercheck",

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

@@ -6,2 +6,4 @@ MasterCheck

[Japanese documents](https://github.com/yuhei-a/wiki/wiki/1.1.x-mastercheck)
## Installation

@@ -8,0 +10,0 @@ ```

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

name: masterCheck.format('String')
})
}),
map2: masterCheck.format('Map', null, masterCheck.format('Number'))
}

@@ -344,3 +345,32 @@ };

});
it('Simple check test.', function(done) {
var dataList = [
{
_id: 'test1',
arr: [ 1, 2 ],
map2: {
a: 1,
b: 2,
c: 3
}
},
{
_id: 'test2',
arr: [ 3, 4 ],
map2: {
d: 4,
e: '5',
f: 6
}
}
];
masterCheck.check('A', dataList, function(err, result) {
should.not.exist(err);
should.exist(result);
result.should.eql({ test2: [ { key: 'map2.e', value: '5', message: '5 should be a Number' } ] });
done();
});
});
});
});
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