Explorar o código

added validation

ryuichi-e %!s(int64=6) %!d(string=hai) anos
pai
achega
b40d501c8a
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      src/server/routes/apiv3/share-links.js

+ 11 - 0
src/server/routes/apiv3/share-links.js

@@ -34,6 +34,17 @@ module.exports = (crowi) => {
     // TODO GW-2616 get all share links associated with the page
   });
 
+  validator.shareLinkStatus = [
+    // validate page id is not empty.
+    body('pageId').not().isEmpty(),
+
+    // validate expireation date is not empty, is not before today and is date.
+    body('expiration').not().isEmpty().isBefore(today.toString),
+
+    // validate the length of description is max 100.
+    body('description').isLength({ min: 0, max: 100 }),
+  ];
+
   /**
    * @swagger
    *