shit element ui & form password validation
shit docs
https://github.com/yiminghe/async-validator#validate
https://element.eleme.io/#/zh-CN/component/form#biao-dan-yan-zheng
passWord: [
{
required: true,
message: "请输入密码",
trigger: "blur",
},
{
min: 3,
max: 20,
message: "长度在 3 到 20 个字符",
trigger: "blur",
}
],
passWordSure: [
{
required: true,
message: "请输入确认密码",
trigger: "blur",
},
{
min: 3,
max: 20,
// pattern: `^${this.$data.form.passWord}$`,
// pattern: `${this.$data.form.passWordSure}`,
message: "两次输入的密码不一致",
// message: " ",
trigger: "blur",
validator: (rule, value, callback) => {
console.log(`value =`, value);
// console.log(`rule =`, rule);
// console.log(`callback =`, callback);
let pwd = this.$data.form.passWord;
console.log(`passWord =`, pwd);
if(pwd === value) {
// green border
callback();
} else {
// red border
callback(new Error("两次输入的密码不一致"));
// this.$refs.formRef.validateField("passWordSure");
}
},
},
],