Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data[type][row][field] = value.replace(/{{\s*([^\}]+)\s*}}/g, function (match, capture) {
let randomPart = _.sample(capture.split('||')),
defaultParts = randomPart.split('?'),
filterParts = defaultParts[0].split('|'),
parts = filterParts[0].split('.');
if (randomPart[0] === '/' && randomPart.endsWith('/')) {
return RandExp.randexp(randomPart.slice(1, -1).replace(/❵/g, '}'));
} else if (parts[0] === 'number' && parts.length === 1) {
return Math.floor(Math.random() * 10);
} else if (parts[0] === 'sentence' && parts.length === 1) {
return sentence();
} else if (parts[0] === 'paragraph' && parts.length === 1) {
return paragraph();
} else if (parts[0] === 'word' && parts.length === 2) {
if (typeof generator[parts[1]] !== 'undefined') {
if (filterParts.length > 1) {
return applyFilters(generator[parts[1]](), filterParts);
} else {
return generator[parts[1]]();
}
}
} else if (parts[0] === 'fake' && parts.length === 2) {
if (typeof chance[parts[1]] === 'function') {
data[type][row][field] = value.replace(/{{\s*([^\}]+)\s*}}/g, function (match, capture) {
let randomPart = _.sample(capture.split('||')),
defaultParts = randomPart.split('?'),
filterParts = defaultParts[0].split('|'),
parts = filterParts[0].split('.');
if (randomPart[0] === '/' && randomPart.endsWith('/')) {
return RandExp.randexp(randomPart.slice(1, -1).replace(/❵/g, '}'));
} else if (parts[0] === 'number' && parts.length === 1) {
return Math.floor(Math.random() * 10);
} else if (parts[0] === 'sentence' && parts.length === 1) {
return sentence();
} else if (parts[0] === 'paragraph' && parts.length === 1) {
return paragraph();
} else if (parts[0] === 'word' && parts.length === 2) {
if (typeof generator[parts[1]] !== 'undefined') {
if (filterParts.length > 1) {
return applyFilters(generator[parts[1]](), filterParts);
} else {
return generator[parts[1]]();
}
}
} else if (parts[0] === 'fake' && parts.length === 2) {
if (typeof chance[parts[1]] === 'function') {
function hostname() {
return Randexp(/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/gm);
}
cepState: function (state) {
return randexp_1.randexp(validate_1.CEPRange[state]);
},
cpf: function () {
cepState: function (state) {
return randexp_1.randexp(validate_1.CEPRange[state]);
},
cpf: function () {
cepState: function (state) {
return randexp_1.randexp(validate_1.CEPRange[state]);
},
cpf: function () {
cepState: (state: string | number) => {
return randexp(CEPRange[state]);
},
certidao: () => {
let opts = {};
let minLength = schema.minLength || 1;
let maxLength = schema.maxLength || minLength + 10;
opts.min = minLength;
opts.max = maxLength;
if (schema.enum && schema.enum.length > 0) {
/**
* If `enum` is defined for the property
*/
mockStr = enumMock(schema);
} else if (schema.pattern) {
/**
* If `pattern` is defined for the property
*/
mockStr = Randexp(schema.pattern);
} else if(Format[schema.format]) {
/**
* If a `format` is defined for the property
*/
mockStr = Format[schema.format].call(null, schema);
} else {
mockStr = Chance.string({
length: Chance.integer(opts),
alpha: true //Use only alpha characters
});
}
return mockStr;
};