Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

znv

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

znv - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

47

dist/preprocessors.js

@@ -39,22 +39,28 @@ "use strict";

case TypeName.ZodNumber:
return (arg) => z
.string()
.regex(/^\d+(\.\d+)?$/, {
message: "Value doesn't appear to be a number!",
})
.transform(Number)
.parse(arg);
return (arg) => {
if (/^\d+(\.\d+)?$/.test(arg))
return Number(arg);
return arg;
};
case TypeName.ZodBigInt:
return (arg) => z
.string()
.regex(/^\d+$/, { message: "Value doesn't appear to be a bigint!" })
.transform(BigInt)
.parse(arg);
return (arg) => {
if (/^\d+$/.test(arg))
return BigInt(arg);
return arg;
};
case TypeName.ZodBoolean:
return (arg) => z
.union([
z.enum(["true", "yes", "1"]).transform(() => true),
z.enum(["false", "no", "0"]).transform(() => false),
])
.parse(arg);
return (arg) => {
switch (arg) {
case "true":
case "yes":
case "1":
return true;
case "false":
case "no":
case "0":
return false;
default:
return arg;
}
};
case TypeName.ZodArray:

@@ -64,2 +70,3 @@ case TypeName.ZodObject:

case TypeName.ZodRecord:
case TypeName.ZodIntersection:
return (arg) => {

@@ -69,2 +76,5 @@ // neither `undefined` nor the empty string are valid json.

return arg;
// the one circumstance when a preprocessor should be able to throw is
// if the json is invalid -- this way the error message will be more
// informative (rather than just "expected x, got string")
return JSON.parse(arg);

@@ -129,3 +139,2 @@ };

case TypeName.ZodUnion:
case TypeName.ZodIntersection:
case TypeName.ZodNativeEnum:

@@ -132,0 +141,0 @@ throw new Error(`Zod type not yet supported: "${typeName}" (PRs welcome)`);

{
"name": "znv",
"version": "0.0.4",
"version": "0.0.5",
"description": "Parse your environment with Zod schemas",

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

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