Created
September 25, 2019 09:50
-
-
Save kusakawazeusu/8bcc90dcd7599a94fbe3d3bf59971868 to your computer and use it in GitHub Desktop.
showApiError
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 {validationResult} from "express-validator"; | |
export function showApiError(req: Request, res: Response, next: NextFunction) { | |
const errors = validationResult(req); | |
if (!errors.isEmpty()) { | |
return res.status(400).json({ errors: errors.array() }); | |
} | |
next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment