我使用的是mobx-react-form(https://foxhound87.github.io/mobx-react-form/docs/getting-started-class.html),并且具有这样的密码规则验证,但是,无论2个值如何,只要我点击确认字段之外,都会出现确认密码错误完全一样:
{
name: 'changePassword',
label: 'Change password',
fields: [
{
name: 'password',
label: t('user:Password'),
rules: 'required|string|min:8',
value: ''
},
{
name: 'password2',
label: t('user:Confirm password'),
rules: 'required|string|same:password',
value: ''
}
]
},
根据文档,这应该可以正常工作。
答案 0 :(得分:2)
没有发现更改密码部分嵌套的事实:
{
name: 'changePassword',
label: 'Change password',
fields: [
{
name: 'password',
label: t('user:Password'),
rules: 'required|string|min:8',
value: ''
},
{
name: 'password2',
label: t('user:Confirm password'),
rules: 'required|string|same:changePassword.password',
value: ''
}
]
},