Mobx反应形式确认密码问题

时间:2018-07-16 10:30:50

标签: javascript reactjs mobx-react

我使用的是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: ''
        }
    ]
},

根据文档,这应该可以正常工作。

enter image description here

1 个答案:

答案 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: ''
        }
    ]
},