@anatine/zod-mock
Advanced tools
Comparing version 3.5.7 to 3.5.8
@@ -5,2 +5,4 @@ # Changelog | ||
### [3.5.8](https://github.com/anatine/zod-plugins/compare/zod-mock-3.5.7...zod-mock-3.5.8) (2022-09-05) | ||
### [3.5.7](https://github.com/anatine/zod-plugins/compare/zod-mock-3.5.6...zod-mock-3.5.7) (2022-08-17) | ||
@@ -7,0 +9,0 @@ |
{ | ||
"name": "@anatine/zod-mock", | ||
"version": "3.5.7", | ||
"version": "3.5.8", | ||
"description": "Zod auto-mock object generator using Faker at @faker-js/faker", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -216,5 +216,12 @@ "use strict"; | ||
} | ||
function parseDiscriminatedUnion(zodRef, options) { | ||
// Map the options to various possible union cases | ||
const potentialCases = [...zodRef._def.options.values()]; | ||
const pick = Math.floor(Math.random() * potentialCases.length); | ||
const mocked = potentialCases[pick]; | ||
return generateMock(mocked, options); | ||
} | ||
function parseNativeEnum(zodRef) { | ||
const { values } = zodRef._def; | ||
const pick = Math.floor(Math.random() * (Object.values(values).length)); | ||
const pick = Math.floor(Math.random() * Object.values(values).length); | ||
const key = Array.from(Object.keys(values))[pick]; | ||
@@ -255,2 +262,3 @@ return values[values[key]]; | ||
ZodUnion: parseUnion, | ||
ZodDiscriminatedUnion: parseDiscriminatedUnion, | ||
}; | ||
@@ -257,0 +265,0 @@ function generateMock(zodRef, options) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32915
322