Created
August 28, 2022 09:02
-
-
Save arifsetyawan/2fc6a229cb3f7900e269166a26e6777d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextFunction, Request, Response } from "express"; | |
import { validationResult } from "express-validator"; | |
import { RequestValidationError } from "../errors/request-validation-error"; | |
export const validateRequest = ( | |
req: Request, | |
res: Response, | |
next: NextFunction | |
) => { | |
const errors = validationResult(req); | |
if (!errors.isEmpty()) { | |
throw new RequestValidationError(errors.array()); | |
} | |
next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment