可以使用正则表达式来验证密码是否至少包含一个大写字母和一个小写字母

pull/4268/head
万洺岐 2024-11-04 22:02:01 +08:00
parent 9ca8a2a9b7
commit c78606c6f7
1 changed files with 8 additions and 5 deletions

View File

@ -88,13 +88,16 @@ export default {
callback() callback()
} }
} }
// 使
const validatePassword = (rule, value, callback) => { const validatePassword = (rule, value, callback) => {
if (value.length < 6) { if (value.length < 6) {
callback(new Error('The password can not be less than 6 digits')) callback(new Error('The password can not be less than 6 digits'));
} else { } else if (!/[a-z]/.test(value) ||!/[A-Z]/.test(value)) {
callback() callback(new Error('The password should contain both uppercase and lowercase letters'));
} } else {
callback();
} }
};
return { return {
loginForm: { loginForm: {
username: 'admin', username: 'admin',