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

@anatine/zod-mock

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anatine/zod-mock - npm Package Compare versions

Comparing version 3.8.2 to 3.8.3

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

### [3.8.3](https://github.com/anatine/zod-plugins/compare/zod-mock-3.8.2...zod-mock-3.8.3) (2023-01-17)
### [3.8.2](https://github.com/anatine/zod-plugins/compare/zod-mock-3.8.1...zod-mock-3.8.2) (2023-01-04)

@@ -7,0 +9,0 @@

2

package.json
{
"name": "@anatine/zod-mock",
"version": "3.8.2",
"version": "3.8.3",
"description": "Zod auto-mock object generator using Faker at @faker-js/faker",

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

@@ -111,3 +111,3 @@ "use strict";

}
const targetStringLength = faker_1.faker.datatype.number(sortedStringOptions);
const targetStringLength = fakerInstance.datatype.number(sortedStringOptions);
/**

@@ -170,6 +170,38 @@ * Returns a random lorem word using `faker.lorem.word(length)`.

if (stringOptions.min != null && val.length < stringOptions.min) {
val = val + faker_1.faker.random.alpha(delta);
val = val + fakerInstance.random.alpha(delta);
}
return val.slice(0, stringOptions.max);
}
function parseBoolean(zodRef, options) {
const fakerInstance = (options === null || options === void 0 ? void 0 : options.faker) || faker_1.faker;
return fakerInstance.datatype.boolean();
}
function parseDate(zodRef, options) {
const fakerInstance = (options === null || options === void 0 ? void 0 : options.faker) || faker_1.faker;
const { checks = [] } = zodRef._def;
let min;
let max;
checks.forEach((item) => {
switch (item.kind) {
case 'min':
min = item.value;
break;
case 'max':
max = item.value;
break;
}
});
if (min !== undefined && max !== undefined) {
return fakerInstance.date.between(min, max);
}
else if (min !== undefined && max === undefined) {
return fakerInstance.date.soon(undefined, min);
}
else if (min === undefined && max !== undefined) {
return fakerInstance.date.recent(undefined, max);
}
else {
return fakerInstance.date.soon();
}
}
function parseNumber(zodRef, options) {

@@ -318,4 +350,4 @@ const fakerInstance = (options === null || options === void 0 ? void 0 : options.faker) || faker_1.faker;

ZodBigInt: parseNumber,
ZodBoolean: () => faker_1.faker.datatype.boolean(),
ZodDate: () => faker_1.faker.date.soon(),
ZodBoolean: parseBoolean,
ZodDate: parseDate,
ZodOptional: parseOptional,

@@ -322,0 +354,0 @@ ZodNullable: parseOptional,

Sorry, the diff of this file is not supported yet

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