![](/img/trans.png)
[英]To Apply the validation and set the password and confirm password same in react native
[英]validatejs confirm password for react-native
我的所有验证都有以下内容:
const validations = {
password: {
presence: true
},
confirmPassword:{
equality: {
attribute: "password",
message: "Passwords do not match",
comparator: function(v1, v2) {
return v1 === v2
}
}
}
}
我想分别显示错误,所以我有以下内容:
let passwordError = validate('password', this.state.password);
let confirmPasswordError = validate("confirmPassword", { confirmPassword: this.state.confirmPassword, password: this.state.password});
密码验证效果很好。 并且confirmPassowrd的存在验证有效,但是相等性检查不起作用。
已经检查过console.log,值是变量v1和v2? 例如,变量v1即将到来:
{confirmPassword:"12345", password:"12345"}
然后就是:
v1.confirmPassword === v1.password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.