Skip to content

Commit

Permalink
feat: adjust tenant id regex
Browse files Browse the repository at this point in the history
  • Loading branch information
rolin999 committed Nov 27, 2024
1 parent 1a0fb97 commit 1ec1686
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def validate_id(self, id: str) -> str:
if not re.fullmatch(TENANT_ID_REGEX, id):
raise ValidationError(
_(
"{} 不符合 租户 ID 的命名规范: 由3-32位字母、数字、连接符(-)字符组成,以字母开头,字母或数字结尾",
"{} 不符合 租户 ID 的命名规范: 由3-32位小写字母、数字、连接符(-)字符组成,以小写字母开头,小写字母或数字结尾", # noqa: E501
).format(id),
) # noqa: E501
)

return id

Expand Down
2 changes: 1 addition & 1 deletion src/bk-user/bkuser/apps/tenant/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from blue_krill.data_types.enum import EnumField, StrStructuredEnum
from django.utils.translation import gettext_lazy as _

TENANT_ID_REGEX = re.compile(r"^[a-zA-Z][a-zA-Z0-9-]{1,30}[a-zA-Z0-9]$")
TENANT_ID_REGEX = re.compile(r"^[a-z][a-z0-9-]{1,30}[a-z0-9]$")

# 自定义字段英文标识命名规则
TENANT_USER_CUSTOM_FIELD_NAME_REGEX = re.compile(r"^[a-zA-Z][a-zA-Z0-9_]{1,30}[a-zA-Z0-9]$")
Expand Down
8 changes: 4 additions & 4 deletions src/bk-user/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,12 @@ msgstr "Tenant ID {} is already in use"

#: bkuser/apis/web/platform_management/serializers.py:111
msgid ""
"{} 不符合 租户 ID 的命名规范: 由3-32位字母、数字、连接符(-)字符组成,以字母开"
"头,字母或数字结尾"
"{} 不符合 租户 ID 的命名规范: 由3-32位小写字母、数字、连接符(-)字符组成,以小写字母开"
"头,小写字母或数字结尾"
msgstr ""
"{} does not meet the naming requirements for Tenant ID: must be composed of "
"3-32 letters, digits, or hyphens (-), starting with a letter and ending with "
"a letter or digit"
"3-32 lowercase letters, digits, or hyphens (-), starting with a lowercase letter and ending with "
"a lowercase letter or digit"

#: bkuser/apis/web/platform_management/serializers.py:124
msgid "密码不符合密码规则:{}"
Expand Down
8 changes: 4 additions & 4 deletions src/bk-user/locale/zh_cn/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ msgstr "租户 ID {} 已被使用"

#: bkuser/apis/web/platform_management/serializers.py:111
msgid ""
"{} 不符合 租户 ID 的命名规范: 由3-32位字母、数字、连接符(-)字符组成,以字母开"
"头,字母或数字结尾"
"{} 不符合 租户 ID 的命名规范: 由3-32位小写字母、数字、连接符(-)字符组成,以小写字母开"
"头,小写字母或数字结尾"
msgstr ""
"{} 不符合 租户 ID 的命名规范: 由3-32位字母、数字、连接符(-)字符组成,以字母开"
"头,字母或数字结尾"
"{} 不符合 租户 ID 的命名规范: 由3-32位小写字母、数字、连接符(-)字符组成,以小写字母开"
"头,小写字母或数字结尾"

#: bkuser/apis/web/platform_management/serializers.py:124
msgid "密码不符合密码规则:{}"
Expand Down

0 comments on commit 1ec1686

Please sign in to comment.