Skip to content

Commit

Permalink
[Feature][Web] Add validation for the format of user phone numbers (D…
Browse files Browse the repository at this point in the history
…ataLinkDC#3625)

Co-authored-by: luoshangjie <[email protected]>
Co-authored-by: 18216499322 <[email protected]>
  • Loading branch information
3 people authored Jul 3, 2024
1 parent c2163b8 commit 3986a9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@ export default {
'user.update': 'Modify User',
'user.username': 'User Name',
'user.usernamePlaceholder': 'Please enter user name',
'user.phoneFormat': 'The format of the phone number is incorrect',

'lineage.getError': 'Cannot Get Lineage',
'lineage.expandField': 'Expand Field(UnSupported)',
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ export default {
'user.update': '修改用户',
'user.username': '用户名',
'user.usernamePlaceholder': '请输入用户名',
'user.phoneFormat': '手机号码格式不正确',

'lineage.getError': '无法获取血缘',
'lineage.expandField': '展开字段(暂未实现)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ type UserFormProps = {
const UserForm: React.FC<UserFormProps> = (props) => {
const { values, form } = props;

const validatePhoneRules = [
{
pattern: /^1[3456789]\d{9}$/,
message: l('user.phoneFormat')
}
];

/**
* user form render
* @returns {JSX.Element}
Expand Down Expand Up @@ -71,6 +78,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {

<ProFormText
name='mobile'
rules={validatePhoneRules}
label={l('user.phone')}
placeholder={l('user.phonePlaceholder')}
/>
Expand Down

0 comments on commit 3986a9b

Please sign in to comment.