Shun Miyazawa 1 год назад
Родитель
Сommit
c51dafa1ac

+ 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')
     .withMessage('pagePathPatterns must be an array of strings')
     .not()
     .not()
     .isEmpty()
     .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
   body('pagePathPatterns.*') // each item of pagePathPatterns
     .isString()
     .isString()