aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-03 10:03:56 +0200
committerChocobozzz <me@florianbigard.com>2022-08-03 10:09:29 +0200
commit35a0a924830d84f9ec28c129ec85cb1f45011fb8 (patch)
tree201e506d454881693db19e22c731d7483bfae247 /server/helpers/custom-validators
parentf59462eca4c39c40a72e48e8bfa9a53fd96d72a2 (diff)
downloadPeerTube-35a0a924830d84f9ec28c129ec85cb1f45011fb8.tar.gz
PeerTube-35a0a924830d84f9ec28c129ec85cb1f45011fb8.tar.zst
PeerTube-35a0a924830d84f9ec28c129ec85cb1f45011fb8.zip
Use same mastodon regex for usernames
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/users.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index b04970108..8a6f6fca1 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -27,9 +27,9 @@ function isUserVideoQuotaDailyValid (value: string) {
27} 27}
28 28
29function isUserUsernameValid (value: string) { 29function isUserUsernameValid (value: string) {
30 const max = USERS_CONSTRAINTS_FIELDS.USERNAME.max 30 return exists(value) &&
31 const min = USERS_CONSTRAINTS_FIELDS.USERNAME.min 31 validator.matches(value, new RegExp(`^[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?$`)) &&
32 return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`)) 32 validator.isLength(value, USERS_CONSTRAINTS_FIELDS.USERNAME)
33} 33}
34 34
35function isUserDisplayNameValid (value: string) { 35function isUserDisplayNameValid (value: string) {