Download src/middleware/validator.js from Mr-Thop/DigitalDB: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/spaces/Mr-Thop/DigitalDB/resolve/main/src/middleware/validator.js
- Command line
-
hf download hf://spaces/Mr-Thop/DigitalDB/src/middleware/validator.js
-
curl -L -o validator.js https://huggingface.co/spaces/Mr-Thop/DigitalDB/resolve/main/src/middleware/validator.js
472 Bytes
| // Input validation middleware | |
| const { validationResult } = require('express-validator'); | |
| const validate = (req, res, next) => { | |
| const errors = validationResult(req); | |
| if (!errors.isEmpty()) { | |
| return res.status(400).json({ | |
| success: false, | |
| error: 'Validation failed', | |
| details: errors.array().map(err => ({ | |
| field: err.param, | |
| message: err.msg | |
| })) | |
| }); | |
| } | |
| next(); | |
| }; | |
| module.exports = validate; | |