6 changed files with 140 additions and 6 deletions
@ -0,0 +1,39 @@ |
|||||
|
import { ValidateTextTypes } from '@/components/DesignForm/validateText' |
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-08-13 16:37:23 |
||||
|
@ 功能: 数字类校验规则 |
||||
|
*/ |
||||
|
|
||||
|
const validateIntConfig: ValidateTextTypes[] = [ |
||||
|
{ |
||||
|
type: 'int', |
||||
|
label: '正整数', |
||||
|
regExp: /^[0-9]*[1-9][0-9]*$/, |
||||
|
message: '请输入正整数', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'number', |
||||
|
label: '数字', |
||||
|
regExp: /^\d+(\.\d+)?$/, |
||||
|
message: '请输入数字', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'money', |
||||
|
label: '金额', |
||||
|
regExp: /^[0-9]+\.?[0-9]{0,2}$/, |
||||
|
message: '请输入正确的金额,最多两位小数', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'float', |
||||
|
label: '浮点数', |
||||
|
regExp: /^(\-|\+)?\d+(\.\d+)?$/, |
||||
|
message: '请输入正确的金额,最多两位小数', |
||||
|
checkbox: false |
||||
|
} |
||||
|
] |
||||
|
|
||||
|
export default validateIntConfig |
||||
@ -0,0 +1,60 @@ |
|||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-08-13 16:33:46 |
||||
|
@ 功能: 文本类校验规则 |
||||
|
*/ |
||||
|
export interface ValidateTextTypes { |
||||
|
type: string |
||||
|
label: string |
||||
|
regExp: RegExp |
||||
|
message: string |
||||
|
checkbox: boolean |
||||
|
} |
||||
|
const validateTextConfig: ValidateTextTypes[] = [ |
||||
|
{ |
||||
|
type: 'mobile', |
||||
|
label: '手机号码', |
||||
|
regExp: /^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/, |
||||
|
message: '请输入手机号码', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'tel', |
||||
|
label: '固话', |
||||
|
regExp: /^0\d{2,3}-\d{7,8}$/, |
||||
|
message: '请输入固定电话号码', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'phone', |
||||
|
label: '固话或手机', |
||||
|
regExp: /^((0\d{2,3}(-?)\d{7,8})|(1[3456789]\d{9}))$/, |
||||
|
message: '请输入固定电话号码或手机号', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'email', |
||||
|
label: '邮箱', |
||||
|
regExp: /^[a-z0-9A-Z._%-]+@([a-z0-9A-Z-]+\.)+[a-zA-Z]{2,4}$/, |
||||
|
message: '请输入邮箱地址', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'card', |
||||
|
label: '身份证', |
||||
|
regExp: |
||||
|
/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/, |
||||
|
message: '请输入身份证号', |
||||
|
checkbox: false |
||||
|
}, |
||||
|
{ |
||||
|
type: 'url', |
||||
|
label: '网址', |
||||
|
regExp: /^https?:\/\/((.)+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?.(\?)?)*)*$/, |
||||
|
message: '请输入网址', |
||||
|
checkbox: false |
||||
|
} |
||||
|
] |
||||
|
|
||||
|
export default validateTextConfig |
||||
Loading…
Reference in new issue