New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1 to 0.2.2

37

lib/mastercheck.js

@@ -148,2 +148,35 @@ /**

/**
* Generate the format of type ObjectArray
* @param {Object} option
* @param {Array} format
* @example
* var option = {
* required: true, // Existence check. Default do not check.
* minLength: 0, // Minimum length check. Default do not check.
* maxLength: 20, // Maximum length check. Default do not check.
* };
*/
Array: function(option, format) {
option = option || {};
this.check = function(data) {
if (!option.required && data === undefined) {
return;
}
if (data === undefined) {
return 'This field is required';
}
if (!Array.isArray(data)) {
return data + ' should be an Array';
}
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 below ' + option.maxLength;
}
};
this.format = format;
},
/**
* Generate the format of type ObjectMap

@@ -222,3 +255,3 @@ * @param {Object} option

} else if (typeof master[i] !== 'undefined') {
errs.push({ key: i, value: JSON.stringify(master[i]), message: '' });
errs.push({ key: i, value: JSON.stringify(master[i]), message: 'Format Error.' });
}

@@ -263,3 +296,3 @@ }

} else if (typeof master[key] !== 'undefined') {
errs.push({ key: key, value: JSON.stringify(master[key]), message: '' });
errs.push({ key: key, value: JSON.stringify(master[key]), message: 'Format Error.' });
}

@@ -266,0 +299,0 @@ }

2

package.json
{
"name": "mastercheck",
"version": "0.2.1",
"version": "0.2.2",
"description": "mastercheck",

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

@@ -12,3 +12,3 @@ MasterCheck

## Usage
### Quick Start
### Example
```

@@ -60,3 +60,3 @@ var mastercheck = require('mastercheck');

### Format Part Option
### Example Format Part Option
#### MasterCheck.Number

@@ -104,2 +104,14 @@ ```

```
#### MasterCheck.Array
```
// For a array of 0-20 have length. Includ { bool: Boolean, num: Number }.
mastercheck.format('Array', {
required: true // Existance check. Default do not check.
minLength: 0, // Minimum length check. Default do not check.
maxLength: 20, // Maximum length check. Default do not check.
}, [
bool: new mastercheck.Boolean(),
num: new mastercheck.Number()
]);
```
#### MasterCheck.Map

@@ -106,0 +118,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