Skip to content

Instantly share code, notes, and snippets.

@kusakawazeusu
Created September 25, 2019 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusakawazeusu/8bcc90dcd7599a94fbe3d3bf59971868 to your computer and use it in GitHub Desktop.
Save kusakawazeusu/8bcc90dcd7599a94fbe3d3bf59971868 to your computer and use it in GitHub Desktop.
showApiError
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