mirror of https://github.com/halo-dev/halo-admin
perf: improve the validation rules for username (#868)
#### What type of PR is this? /kind improvement #### What this PR does / why we need it: 优化用户名的校验规则,目前采用 DNS 名称的规则,即:必须以字母(a-z或A-Z)开头,并包含字母数字字符(a-z,A-Z,0-9)和连字符(-)。每一段名称以字母结尾(a-z或A-Z)。名称以点(.)分隔 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3239 #### Screenshots: #### Special notes for your reviewer: 测试方式: 1. 新建用户,检查用户名输入规则是否符合预期。 #### Does this PR introduce a user-facing change? ```release-note 优化 Console 端新建用户时,用户名的校验规则。 ```pull/881/head^2
parent
816feb9937
commit
43c5effcd0
|
@ -173,7 +173,17 @@ const handleCreateUser = async () => {
|
|||
label="用户名"
|
||||
type="text"
|
||||
name="name"
|
||||
validation="required|alphanumeric|length:0,50"
|
||||
:validation="[
|
||||
['required'],
|
||||
['length:0,63'],
|
||||
[
|
||||
'matches',
|
||||
/^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/,
|
||||
],
|
||||
]"
|
||||
:validation-messages="{
|
||||
matches: '请输入有效的用户名',
|
||||
}"
|
||||
></FormKit>
|
||||
<FormKit
|
||||
id="displayNameInput"
|
||||
|
|
Loading…
Reference in New Issue