Created
May 14, 2024 14:54
-
-
Save solanoize/4b5f3ae36d4cc2d6782649802efe0930 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const Validate = (validations) => { | |
| return async (err, req, res, next) => { | |
| for (let validation of validations) { | |
| await validation.run(req); | |
| // if (result.errors.length) break; | |
| } | |
| const errors = validationResult(req); | |
| const errs = _.chain(errors.errors).groupBy("path").value() | |
| console.log("test", errors.isEmpty()) | |
| if (errors.isEmpty()) { | |
| req.cleanedData = matchedData(req); | |
| return next(); | |
| } | |
| res.status(400).json(errs); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment