nestjs-zod-config
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -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>; |
"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; | ||
} | ||
}); |
{ | ||
"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 @@ ], |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15758
259
0