Parcourir la source

added validation

ryuichi-e il y a 6 ans
Parent
commit
b40d501c8a
1 fichiers modifiés avec 11 ajouts et 0 suppressions
  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
    *