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.9 to 3.5.10

2

CHANGELOG.md

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

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

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

2

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

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

@@ -25,3 +25,11 @@ import { z, ZodTypeAny } from 'zod';

mapEntriesLength?: number;
/**
* Set to true to throw an exception instead of returning undefined when encountering an unknown `ZodType`
*/
throwOnUnknownType?: boolean;
}
export declare function generateMock<T extends ZodTypeAny>(zodRef: T, options?: GenerateMockOptions): z.infer<typeof zodRef>;
export declare class ZodMockError extends Error {
typeName: string;
constructor(typeName: string);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateMock = void 0;
exports.ZodMockError = exports.generateMock = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -290,3 +290,2 @@ const faker_1 = require("@faker-js/faker");

function generateMock(zodRef, options) {
var _a;
try {

@@ -297,6 +296,6 @@ const typeName = zodRef._def.typeName;

}
else {
else if ((options === null || options === void 0 ? void 0 : options.backupMocks) && typeName in options.backupMocks) {
// check for a generator match in the options.
// workaround for unimplemented Zod types
const generator = (_a = options === null || options === void 0 ? void 0 : options.backupMocks) === null || _a === void 0 ? void 0 : _a[typeName];
const generator = options.backupMocks[typeName];
if (generator) {

@@ -306,5 +305,11 @@ return generator();

}
else if (options === null || options === void 0 ? void 0 : options.throwOnUnknownType) {
throw new ZodMockError(typeName);
}
return undefined;
}
catch (err) {
if (err instanceof ZodMockError) {
throw err;
}
console.error(err);

@@ -315,2 +320,9 @@ return undefined;

exports.generateMock = generateMock;
class ZodMockError extends Error {
constructor(typeName) {
super(`Unable to generate a mock value for ZodType ${typeName}.`);
this.typeName = typeName;
}
}
exports.ZodMockError = ZodMockError;
//# sourceMappingURL=zod-mock.js.map

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