13 lines
278 B
JavaScript
13 lines
278 B
JavaScript
|
|
const RequestValidator = (schema) => {
|
||
|
|
return async (req, res, next) => {
|
||
|
|
try {
|
||
|
|
req.body = await schema.parseAsync(req.body);
|
||
|
|
next();
|
||
|
|
}
|
||
|
|
catch (err) {
|
||
|
|
next(err);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
};
|
||
|
|
export default RequestValidator;
|