完善添加银行卡功能
This commit is contained in:
@@ -12,6 +12,9 @@ const ID_CARD_REGEX = /(^\d{15}$)|(^\d{18}$)|(^\d{17}[\dXx]$)/
|
||||
/** 密码强度(至少8位,包含数字和字母) */
|
||||
const PASSWORD_REGEX = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/
|
||||
|
||||
/** 交易密码(6–20 位,必须包含数字 + 字母(大小写均可)) */
|
||||
const TRANSACTION_PASSWORD_REGEX = /^(?=.*\d)(?=.*[a-zA-Z]).{6,20}$/
|
||||
|
||||
/**
|
||||
* 校验手机号
|
||||
* @param {string} phone - 待校验的手机号
|
||||
@@ -82,3 +85,20 @@ export const validateIdCard = idCard => {
|
||||
}
|
||||
return { valid: true, message: '' }
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验交易密码
|
||||
* @param {string} password - 待校验的密码
|
||||
* @returns {{ valid: boolean, message: string }}
|
||||
*/
|
||||
|
||||
export const validateTransactionPassword = (password, name = '密码') => {
|
||||
if (!password) return { valid: false, message: `${name}不能为空` }
|
||||
if (password.length < 6) {
|
||||
return { valid: false, message: `${name}长度不能少于6位` }
|
||||
}
|
||||
if (!TRANSACTION_PASSWORD_REGEX.test(password)) {
|
||||
return { valid: false, message: `${name}需包含字母和数字` }
|
||||
}
|
||||
return { valid: true, message: '' }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user