refactor(models,validators): tighten validation and standardize couchdbService usage\n\n- User: fix bio length check, error messages, and typos (couchdbService calls and bcrypt prefix).\n- UserBadge: use array from find(), return couchdbService results consistently, and call updateDocument/deleteDocument APIs.\n- profileValidator: switch custom URL regex to express-validator isURL with protocol requirement.\n\n🤖 Generated with [AI Assistant]\n\nCo-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const { body, validationResult } = require("express-validator");
|
||||
|
||||
const URL_REGEX = /^(https?|ftp):\\/\\/[^\\s\\/$.?#].[^\\s]*$/i;
|
||||
// URL validation handled via express-validator isURL
|
||||
|
||||
const validateProfile = [
|
||||
body("bio")
|
||||
@@ -11,22 +11,22 @@ const validateProfile = [
|
||||
body("website")
|
||||
.optional()
|
||||
.if(body("website").notEmpty())
|
||||
.matches(URL_REGEX)
|
||||
.isURL({ protocols: ["http", "https", "ftp"], require_protocol: true })
|
||||
.withMessage("Invalid website URL."),
|
||||
body("social.twitter")
|
||||
.optional()
|
||||
.if(body("social.twitter").notEmpty())
|
||||
.matches(URL_REGEX)
|
||||
.isURL({ protocols: ["http", "https", "ftp"], require_protocol: true })
|
||||
.withMessage("Invalid Twitter URL."),
|
||||
body("social.github")
|
||||
.optional()
|
||||
.if(body("social.github").notEmpty())
|
||||
.matches(URL_REGEX)
|
||||
.isURL({ protocols: ["http", "https", "ftp"], require_protocol: true })
|
||||
.withMessage("Invalid Github URL."),
|
||||
body("social.linkedin")
|
||||
.optional()
|
||||
.if(body("social.linkedin").notEmpty())
|
||||
.matches(URL_REGEX)
|
||||
.isURL({ protocols: ["http", "https", "ftp"], require_protocol: true })
|
||||
.withMessage("Invalid LinkedIn URL."),
|
||||
body("privacySettings.profileVisibility")
|
||||
.optional()
|
||||
|
||||
Reference in New Issue
Block a user