freight-web/src/utils/validate.ts

19 lines
948 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const valid = {
mobile: {
pattern: /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/,
message: '请输入正确的手机号码',
},
password: {
pattern: /^((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!;:@#$%?^&*_-]))([a-zA-Z0-9!;:@#$%?^&*_-]){6,16}$/,
message: '密码必须包含大小写字母、数字、特殊字符',
},
username: /^[a-zA-Z]{4,12}$/, //长度4~12英文大小写字母
email: /^(\w+(_|-|.)*)+@(\w+(-)?)+(.\w{2,})+$/,//用户名 @ 域名域名后缀至少2个字符
valid_number: /[^\d]/g,
// valid_password: /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[A-Za-z\d`~!@#$%^&*()_+<>?:"{},.\/\\;'[\]]{6,20}$/, // 8位 大小写 数字 和下划线
valid_no_space: /\s+/g, //不可输入空格
valid_no_cn:/[\u4E00-\u9FA5]/g, // 不可输入中文
valid_number_en: /^[a-zA-Z0-9]+$/, // 只能输入数字和英文
}
export default valid