浏览代码

add validation for bookmarks

zahmis 5 年之前
父节点
当前提交
ef49903fe1
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/server/routes/apiv3/bookmarks.js

+ 9 - 0
src/server/routes/apiv3/bookmarks.js

@@ -145,6 +145,15 @@ module.exports = (crowi) => {
    */
    */
   validator.myBookmarkList = [
   validator.myBookmarkList = [
     query('page').isInt({ min: 1 }),
     query('page').isInt({ min: 1 }),
+    query('pageLimitationM').custom((value) => {
+      if (value === undefined) {
+        return 10;
+      }
+      if (value > 100) {
+        throw new Error('You should set less than 100 or not to set pageLimitationM.');
+      }
+      return value;
+    }),
   ];
   ];
 
 
   router.get('/:userId', accessTokenParser, loginRequired, validator.myBookmarkList, apiV3FormValidator, async(req, res) => {
   router.get('/:userId', accessTokenParser, loginRequired, validator.myBookmarkList, apiV3FormValidator, async(req, res) => {