diff --git a/package-lock.json b/package-lock.json index 8123290..c650dc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@types/express": "^5.0.6", - "zod": "^3.22.4" + "zod": "^4.4.3" }, "devDependencies": { "@types/jest": "^30.0.0", @@ -5875,9 +5875,9 @@ } }, "node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", + "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index 7d0bc37..b3c469b 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ ], "dependencies": { "@types/express": "^5.0.6", - "zod": "^3.22.4" + "zod": "^4.4.3" }, "peerDependencies": { "express": ">=5.0.0 <6" diff --git a/src/middleware/validator.ts b/src/middleware/validator.ts index 4324e43..3ab6e33 100644 --- a/src/middleware/validator.ts +++ b/src/middleware/validator.ts @@ -45,7 +45,7 @@ export function validate(input: ValidatorOptions | ValidationSchema) { const result = options.schema.body.safeParse(req.body); if (!result.success) { errors.push( - ...result.error.errors.map((e: z.ZodIssue) => `body.${e.path.join('.')}: ${e.message}`) + ...result.error.issues.map((e: z.ZodIssue) => `body.${e.path.join('.')}: ${e.message}`) ); } else if (options.sanitize) { req.body = result.data; @@ -61,7 +61,7 @@ export function validate(input: ValidatorOptions | ValidationSchema) { const result = options.schema.query.safeParse(req.query); if (!result.success) { errors.push( - ...result.error.errors.map((e: z.ZodIssue) => `query.${e.path.join('.')}: ${e.message}`) + ...result.error.issues.map((e: z.ZodIssue) => `query.${e.path.join('.')}: ${e.message}`) ); } else if (options.sanitize) { req.query = result.data as any; @@ -77,7 +77,7 @@ export function validate(input: ValidatorOptions | ValidationSchema) { const result = options.schema.params.safeParse(req.params); if (!result.success) { errors.push( - ...result.error.errors.map( + ...result.error.issues.map( (e: z.ZodIssue) => `params.${e.path.join('.')}: ${e.message}` ) ); @@ -95,7 +95,7 @@ export function validate(input: ValidatorOptions | ValidationSchema) { const result = options.schema.headers.safeParse(req.headers); if (!result.success) { errors.push( - ...result.error.errors.map( + ...result.error.issues.map( (e: z.ZodIssue) => `headers.${e.path.join('.')}: ${e.message}` ) ); @@ -153,7 +153,7 @@ export class DeepObjectValidator { return { success: false, - errors: result.error.errors.map((e: { message: string }) => e.message), + errors: result.error.issues.map((e: { message: string }) => e.message), }; }