NextNodeTemplate/backend/middleware/validate.js
DosAi 0fe27033b5
Some checks are pending
CI/CD / lint-and-build (push) Waiting to run
fix: Correct validate middleware to use standard express-validator pattern
2025-11-02 17:17:38 +03:00

21 lines
508 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Middleware для валидации запросов с express-validator
// Используется после применения валидаций как middleware
const { validationResult } = require('express-validator');
const validate = (req, res, next) => {
const errors = validationResult(req);
if (errors.isEmpty()) {
return next();
}
res.status(400).json({
success: false,
error: 'Validation failed',
errors: errors.array(),
});
};
module.exports = validate;