فهرست منبع

fix: allow field to be null

poeti8 5 سال پیش
والد
کامیت
7a1ae9ad27
1فایلهای تغییر یافته به همراه5 افزوده شده و 5 حذف شده
  1. 5 5
      server/handlers/validators.ts

+ 5 - 5
server/handlers/validators.ts

@@ -57,14 +57,14 @@ export const createLink = [
     .custom(value => URL.parse(value).host !== env.DEFAULT_DOMAIN)
     .withMessage(`${env.DEFAULT_DOMAIN} URLs are not allowed.`),
   body("password")
-    .optional()
+    .optional({ nullable: true })
     .custom(checkUser)
     .withMessage("Only users can use this field.")
     .isString()
     .isLength({ min: 3, max: 64 })
     .withMessage("Password length must be between 3 and 64."),
   body("customurl")
-    .optional()
+    .optional({ nullable: true })
     .custom(checkUser)
     .withMessage("Only users can use this field.")
     .isString()
@@ -76,19 +76,19 @@ export const createLink = [
     .custom(value => !preservedUrls.some(url => url.toLowerCase() === value))
     .withMessage("You can't use this custom URL."),
   body("reuse")
-    .optional()
+    .optional({ nullable: true })
     .custom(checkUser)
     .withMessage("Only users can use this field.")
     .isBoolean()
     .withMessage("Reuse must be boolean."),
   body("description")
-    .optional()
+    .optional({ nullable: true })
     .isString()
     .trim()
     .isLength({ min: 0, max: 2040 })
     .withMessage("Description length must be between 0 and 2040."),
   body("domain")
-    .optional()
+    .optional({ nullable: true })
     .custom(checkUser)
     .withMessage("Only users can use this field.")
     .isString()