Spaces:
Running
Running
Download src/middleware/validate.js from AndreaNotes1/auth-app-api: direct link, hf CLI and curl.
- Browser
- Download file 381 Bytes
-
https://huggingface.co/spaces/AndreaNotes1/auth-app-api/resolve/main/src/middleware/validate.js
- Command line
-
hf download hf://spaces/AndreaNotes1/auth-app-api/src/middleware/validate.js
-
curl -L -o validate.js https://huggingface.co/spaces/AndreaNotes1/auth-app-api/resolve/main/src/middleware/validate.js
381 Bytes
| const { validationResult } = require("express-validator"); | |
| function validate(req, res, next) { | |
| const errors = validationResult(req); | |
| if (!errors.isEmpty()) { | |
| return res.status(400).json({ | |
| error: "Validation failed.", | |
| details: errors.array().map((e) => ({ field: e.path, message: e.msg })), | |
| }); | |
| } | |
| next(); | |
| } | |
| module.exports = { validate }; | |