Socket
Socket
Sign inDemoInstall

nestjs-zod-config

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-zod-config - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

8

dist/utilities.d.ts

@@ -11,1 +11,9 @@ import { z } from 'zod';

export declare const safeBooleanCoerce: z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodString]>, boolean, string | boolean>;
/**
* This is a utility function that can be used to parse a comma delimited string to an array of strings.
*/
export declare const commaDelimitedArray: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], unknown>;
/**
* This is a utility function that can be used to transform a JSON string into an object.
*/
export declare const jsonStringCoerce: z.ZodEffects<z.ZodString, any, string>;

24

dist/utilities.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.safeBooleanCoerce = void 0;
exports.jsonStringCoerce = exports.commaDelimitedArray = exports.safeBooleanCoerce = void 0;
const zod_1 = require("zod");

@@ -25,1 +25,23 @@ /**

});
/**
* This is a utility function that can be used to parse a comma delimited string to an array of strings.
*/
exports.commaDelimitedArray = zod_1.z.preprocess((input, ctx) => {
if (typeof input === 'string') {
return input.split(',').map((s) => s.trim());
}
ctx.addIssue({ code: 'custom', message: 'Invalid comma delimited array - must be a string' });
return zod_1.z.NEVER;
}, zod_1.z.array(zod_1.z.string()).min(1));
/**
* This is a utility function that can be used to transform a JSON string into an object.
*/
exports.jsonStringCoerce = zod_1.z.string().transform((input, ctx) => {
try {
return JSON.parse(input);
}
catch (e) {
ctx.addIssue({ code: 'custom', message: 'Invalid JSON string - cannot be parsed' });
return zod_1.z.NEVER;
}
});

2

package.json
{
"name": "nestjs-zod-config",
"version": "2.0.0",
"version": "2.1.0",
"description": "NestJS module to load, type and validate configuration using Zod",

@@ -5,0 +5,0 @@ "keywords": [

@@ -54,4 +54,4 @@ # NestJS Zod Config

ZodConfigModule.forRoot({
isGlobal: true, // optional, defaults to true
config: AppConfig,
isGlobal: true, // optional, defaults to `false`
}),

@@ -58,0 +58,0 @@ ],

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