Browse Source

add validation

sooouh 6 years ago
parent
commit
3e3466e19f

+ 1 - 0
src/client/js/services/MarkDownSettingContainer.js

@@ -62,6 +62,7 @@ export default class MarkDownSettingContainer extends Container {
 
     const response = await this.appContainer.apiv3.put('/markdown-setting/presentation', {
       pageBreakOption: this.state.pageBreakOption,
+      customRegularExpression: this.state.customRegularExpression,
     });
 
     return response;

+ 6 - 7
src/server/routes/apiv3/markdown-setting.js

@@ -30,7 +30,7 @@ module.exports = (crowi) => {
   const { ApiV3FormValidator } = crowi.middlewares;
 
   validator.presentationSetting = [
-    // body('').isBoolean(),
+    body('pageBreakOption').isInt().not().isEmpty(),
   ];
 
   /**
@@ -39,10 +39,10 @@ module.exports = (crowi) => {
    *  paths:
    *    /_api/v3/markdown-setting/presentation:
    *      put:
-   *        tags: [MarkDownSetting]
+   *        tags: [Users]
    *        description: Update presentation
    *        parameters:
-   *          - name: markdown:presentation:isEnabledPresentation
+   *          - name: markdown:presentation:isEnabledPrevention
    *            in: query
    *            description: enable presentation
    *            schema:
@@ -64,13 +64,12 @@ module.exports = (crowi) => {
    *                      description: new presentation params
    */
   router.put('/presentation', loginRequiredStrictly, adminRequired, csrf, validator.presentationSetting, ApiV3FormValidator, async(req, res) => {
-    if (req.body.isEnabledXss && req.body.presentationOption == null) {
-      return res.apiv3Err(new ErrorV3('presentation option is required'));
+    if (req.body.pageBreakOption === 3 && req.body.customRegularExpression === '') {
+      return res.apiv3Err(new ErrorV3('customRegularExpression is required'));
     }
 
     const presentationParams = {
-      'markdown:presentation:isEnabledPresentation': req.body.isEnabledPresentation,
-      'markdown:presentation:option': req.body.presentationOption,
+      'markdown:presentation:pageBreakOption': req.body.pageBreakOption,
     };
 
     try {