소스 검색

add validation

Shun Miyazawa 1 년 전
부모
커밋
c51dafa1ac
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      apps/app/src/features/openai/server/routes/middlewares/upsert-ai-assistant-validator.ts

+ 6 - 1
apps/app/src/features/openai/server/routes/middlewares/upsert-ai-assistant-validator.ts

@@ -30,7 +30,12 @@ export const upsertAiAssistantValidator: ValidationChain[] = [
     .withMessage('pagePathPatterns must be an array of strings')
     .not()
     .isEmpty()
-    .withMessage('pagePathPatterns must not be empty'),
+    .withMessage('pagePathPatterns must not be empty')
+    .custom((pagePathPattens: string[]) => {
+      if (pagePathPattens.length > 300) {
+        throw new Error('pagePathPattens must be an array of strings with a maximum length of 300');
+      }
+    }),
 
   body('pagePathPatterns.*') // each item of pagePathPatterns
     .isString()