Skip to content

Commit

Permalink
update zod types validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dileepainivossl committed Aug 5, 2024
1 parent cb4facd commit d5fdf0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/middlewares/requestValidator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type NextFunction, type Request, type Response } from 'express'
import { ZodError, type ZodSchema } from 'zod'

export const requestBodyValidator = (schema: ZodSchema<any, any, any>) => {
export const requestBodyValidator = <T extends ZodSchema>(schema: T) => {
return (req: Request, res: Response, next: NextFunction) => {
try {
schema.parse(req.body)
Expand All @@ -21,7 +21,7 @@ export const requestBodyValidator = (schema: ZodSchema<any, any, any>) => {
}
}

export const requestQueryValidator = (schema: ZodSchema<any, any, any>) => {
export const requestQueryValidator = <T extends ZodSchema>(schema: T) => {
return (req: Request, res: Response, next: NextFunction) => {
try {
schema.parse(req.query)
Expand Down

0 comments on commit d5fdf0b

Please sign in to comment.