mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 06:04:05 +00:00
link creation/deletion
This commit is contained in:
29
validators/operations.js
Normal file
29
validators/operations.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { body, header, param, query } = require("express-validator");
|
||||
|
||||
const typedefs = require("../typedefs");
|
||||
|
||||
/**
|
||||
* @param {typedefs.Req} req
|
||||
* @param {typedefs.Res} res
|
||||
* @param {typedefs.Next} next
|
||||
*/
|
||||
const createLinkValidator = async (req, res, next) => {
|
||||
await body("from")
|
||||
.notEmpty()
|
||||
.withMessage("from not defined in body")
|
||||
.isURL()
|
||||
.withMessage("from must be a valid link")
|
||||
.run(req);
|
||||
await body("to")
|
||||
.notEmpty()
|
||||
.withMessage("to not defined in body")
|
||||
.isURL()
|
||||
.withMessage("to must be a valid link")
|
||||
.run(req);
|
||||
next();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createLinkValidator,
|
||||
removeLinkValidator: createLinkValidator
|
||||
}
|
||||
Reference in New Issue
Block a user