Skip to content

Commit

Permalink
fix: 修复昵称正则不一致问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 24, 2023
1 parent 4ef741a commit 8e506dc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class UserRequest extends BaseRequest {
*/
@Schema(description = "昵称", example = "张三")
@NotBlank(message = "昵称不能为空")
@Pattern(regexp = "^[\\u4e00-\\u9fa5a-zA-Z0-9_-]{4,30}$", message = "昵称长度为 4 到 30 位,可以包含中文、字母、数字、下划线,短横线")
@Pattern(regexp = RegexConsts.GENERAL_NAME, message = "昵称长度为 2 到 30 位,可以包含中文、字母、数字、下划线,短横线")
private String nickname;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,14 @@
required: true,
message: t('userCenter.basicInfo.form.error.required.username'),
},
{
match: /^[a-zA-Z][a-zA-Z0-9_]{3,15}$/,
message: t('userCenter.basicInfo.form.error.match.username'),
},
],
nickname: [
{
required: true,
message: t('userCenter.basicInfo.form.error.required.nickname'),
},
{
match: /^[\u4e00-\u9fa5a-zA-Z0-9_-]{1,20}$/,
match: /^[\u4e00-\u9fa5a-zA-Z0-9_-]{2,30}$/,
message: t('userCenter.basicInfo.form.error.match.nickname'),
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ export default {
'userCenter.basicInfo.form.placeholder.nickname': 'Please enter nickname',

'userCenter.basicInfo.form.error.required.username': 'Please enter username',
'userCenter.basicInfo.form.error.match.username':
'Username are 4 to 16 characters long and can contain letters, numbers, underscores, and start with a letter',
'userCenter.basicInfo.form.error.required.nickname': 'Please enter nickname',
'userCenter.basicInfo.form.error.match.nickname':
'Nickname are 1 to 20 digits long and can contain Chinese, letters, numbers, underscores, dashes',
'Nickname are 2 to 30 digits long and can contain Chinese, letters, numbers, underscores, dashes',

'userCenter.basicInfo.form.save': 'Save',
'userCenter.basicInfo.form.save.success': 'Save success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ export default {
'userCenter.basicInfo.form.placeholder.nickname': '请输入昵称',

'userCenter.basicInfo.form.error.required.username': '请输入用户名',
'userCenter.basicInfo.form.error.match.username':
'长度为 4 到 16 位,可以包含字母、数字,下划线,以字母开头',
'userCenter.basicInfo.form.error.required.nickname': '请输入昵称',
'userCenter.basicInfo.form.error.match.nickname':
'长度为 120 位,可以包含中文、字母、数字、下划线,短横线',
'长度为 230 位,可以包含中文、字母、数字、下划线,短横线',

'userCenter.basicInfo.form.save': '保存',
'userCenter.basicInfo.form.save.success': '保存成功',
Expand Down

0 comments on commit 8e506dc

Please sign in to comment.