Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
mockdata-generator
Advanced tools
Collection of data generators to create complex data structures and any number of records
A library of mock data object generator. Allows developers and users to define real life looking mock data.
npm install generator --save-dev
The following is a complete program that generates 10 records of data
/**
* This program runs inside a YUI instance.
* This is not a requisite for using the *mockdata-generator*.
* In the first line of code require provides an instance to YUI and a closure for the rest of the code.
**/
require('mockdata-generator/node_modules/yui').YUI().use(function (Y) {
"use strict";
var Generator,
meta,
gen;
/**
* This will get the constructor of the main class
* The constructor accepts a configuration object with these properties
* 'name': An optional name of the record
* 'metadata': An array of descriptions for each of the attributes of the object
**/
Generator = require('mockdata-generator').Generator;
meta = {
'name': 'Mockdata test set',
'metadata': [
{
'columnName': 'accountOwner',
'dataType': 'Name',
'order': 'fl'
},
{
'columnName': 'days',
'dataType': 'Integer',
'min': 10,
'max': 30
},
{
'columnName': 'accountName',
'dataType': 'String',
'min': 6,
'max': 30
},
{
'columnName': 'accountNumber',
'dataType': 'Pattern',
'pattern': '###-AA-###-aaa-####'
},
{
'columnName': 'beneficiaryContact',
'dataType': 'Name',
'order': 'lf'
},
{
'columnName': 'balance',
'dataType': 'Currency',
'min': 50,
'max': 1000
},
{
'columnName': 'txDate',
'dataType': 'Date',
'min': 10,
'max': 30
},
{
'columnName': 'description',
'dataType': 'Ipsum',
'paragraphNum': 1,
'wordMin': 10,
'wordMax': 30
},
{
'columnName': 'beneficiary',
'dataType': 'OneOfList',
'listName': 'ListBase.Beneficiaries',
'mode': 'sequence',
'index': 0
},
{
'columnName': 'categoryName',
'dataType': 'OneOfList',
'list': ['A', 'B', 'C', 'D', 'E', 'F'],
'mode': 'shuffle'
}
]
};
gen = new Generator(meta);
Y.log(gen.getValue(10));
});
mockdata-generator provides a way to generate data in the following dataTypes
The base clase for all the other generators. It implements several attributes and methods. Base is not used to generate data and it provides all the common functionality for the other data types
Attribute | Description |
---|---|
columnName | Identifies the attribute inside the object. It must be unique for the object |
dataType | The data type of the attribute. Any of the names in the dataType list above |
min | The minimum value of a range. Not all the data types require a min |
max | The maximum value of a range. Not all the data types require a max |
An Array datatype will generate a number of values in the range of (min, max).
Attribute | Description |
---|---|
metadata | An array of data descriptors |
min | The minimum number of values to generate |
max | The maximum number of values to generate |
Generates a random numeric value in the (min, max) range, assign one of the listed currencies and generates an object with three attributes: currency, value and formatted value, for instance
{
currency: 'MXN',
value: 943.9473666250706,
formatted: '943.95 MXN'
}
Attribute | Description |
---|---|
currencyCode | A list of the currencies to select. The default value is ['AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'HKD', 'JPY', 'MXN', 'NZD', 'PHP', 'SEK', 'SGD', 'THB', 'USD', 'ZAR'] |
decimalPlaces | Number of decimal places, default 2 |
decimalSeparator | Character to separate decimal fractions. Default "." |
thousandsSeparator | Character to separate thousands. Default "," |
min | The minimum value in range |
max | The maximum value in range |
FAQs
Collection of data generators to create complex data structures and any number of records
The npm package mockdata-generator receives a total of 0 weekly downloads. As such, mockdata-generator popularity was classified as not popular.
We found that mockdata-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.