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.5.8 to 3.5.9

2

CHANGELOG.md

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

### [3.5.9](https://github.com/anatine/zod-plugins/compare/zod-mock-3.5.8...zod-mock-3.5.9) (2022-09-05)
### [3.5.8](https://github.com/anatine/zod-plugins/compare/zod-mock-3.5.7...zod-mock-3.5.8) (2022-09-05)

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

2

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

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

@@ -17,4 +17,11 @@ import { z, ZodTypeAny } from 'zod';

backupMocks?: Record<string, () => any | undefined>;
/**
* How many entries to create for records
*/
recordKeysLength?: number;
/**
* How many entries to create for Maps
*/
mapEntriesLength?: number;
}
export declare function generateMock<T extends ZodTypeAny>(zodRef: T, options?: GenerateMockOptions): z.infer<typeof zodRef>;

@@ -211,2 +211,26 @@ "use strict";

}
function parseSet(zodRef, options) {
var _a, _b;
let min = ((_a = zodRef._def.minSize) === null || _a === void 0 ? void 0 : _a.value) != null ? zodRef._def.minSize.value : 1;
const max = ((_b = zodRef._def.maxSize) === null || _b === void 0 ? void 0 : _b.value) != null ? zodRef._def.maxSize.value : 5;
// prevents arrays from exceeding the max regardless of the min.
if (min > max) {
min = max;
}
const targetLength = faker_1.faker.datatype.number({ min, max });
const results = new Set();
while (results.size < targetLength) {
results.add(generateMock(zodRef._def.valueType, options));
}
return results;
}
function parseMap(zodRef, options) {
var _a;
const targetLength = (_a = options === null || options === void 0 ? void 0 : options.mapEntriesLength) !== null && _a !== void 0 ? _a : 1;
const results = new Map();
while (results.size < targetLength) {
results.set(generateMock(zodRef._def.keyType, options), generateMock(zodRef._def.valueType, options));
}
return results;
}
function parseEnum(zodRef) {

@@ -262,2 +286,4 @@ const values = zodRef._def.values;

ZodUnion: parseUnion,
ZodSet: parseSet,
ZodMap: parseMap,
ZodDiscriminatedUnion: parseDiscriminatedUnion,

@@ -264,0 +290,0 @@ };

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