New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zod-search-params

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-search-params - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

15

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseSearchParams = void 0;
var schemaChanges = [];
var modifySchema = function (zodType, key, object) {

@@ -16,2 +17,3 @@ if (zodType._def.typeName === 'ZodBoolean') {

zodType._def.coerce = true;
schemaChanges.push(zodType._def);
return;

@@ -29,2 +31,3 @@ }

zodType._def.coerce = true;
schemaChanges.push(zodType._def);
}

@@ -38,2 +41,9 @@ return;

};
var revertSchema = function () {
schemaChanges.forEach(function (type) {
if ('coerce' in type) {
type.coerce = false;
}
});
};
var expectsArray = function (zodType) {

@@ -101,5 +111,8 @@ if (!(zodType === null || zodType === void 0 ? void 0 : zodType._def))

try {
return schema.parse(processedObject);
var parsedQuery = schema.parse(processedObject);
revertSchema();
return parsedQuery;
}
catch (_b) {
revertSchema();
// @ts-expect-error Undefined is return only in specific case, not sure how to fix this on the types level

@@ -106,0 +119,0 @@ return undefined;

5

package.json
{
"name": "zod-search-params",
"version": "0.1.1",
"version": "0.1.2",
"private": false,
"description": "Zod utility for parsing search params",
"license": "MIT",
"keywords": [
"zod",
"search params",
"query params",
"url search params",
"url query params",
"next.js",

@@ -11,0 +14,0 @@ "nextjs",

@@ -16,3 +16,3 @@ # zod-search-params

### Define Schema
Do **NOT** use `coerce` in the schema, coerce is applied automatically (to prevent casting `undefined` to `"undefined"` etc.) for enabled types, when it's needed.
```ts

@@ -19,0 +19,0 @@ const schema = z.object({

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