Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thedevs-network/kutt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpoeti8 <ezzati.upt@gmail.com>2020-07-29 17:51:55 +0300
committerpoeti8 <ezzati.upt@gmail.com>2020-07-29 17:51:55 +0300
commit7a1ae9ad27e9b203714a230e65c304362783c3d1 (patch)
tree640424ef0e1e7518e7a50588179b080adc725569
parent3aab6cb73d341b5604b60c859fe96bb7894b6c48 (diff)
fix: allow field to be null
-rw-r--r--server/handlers/validators.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/server/handlers/validators.ts b/server/handlers/validators.ts
index 9e15cfd..954cc1a 100644
--- a/server/handlers/validators.ts
+++ b/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()