我有密码重设表格:
{formItem(
props.form.getFieldDecorator('currentPassword', {
rules: [{ min: 6 },
{ validator: maybeMustBeRequared }
],
})(<Input type="password" />),
{
label: tUsers.currentPassword,
},
)}
{formItem(
props.form.getFieldDecorator('newPassword', {
rules: [{ min: 6 }],
})(<Input type="password" />),
{
label: tUsers.newPassword,
},
)}
{formItem(
props.form.getFieldDecorator('confirmPassword', {
rules: [
{ min: 6 },
{
validator: compareToFirstPassword,
},
],
})(<Input type="password" />),
{
label: tUsers.confirmPassword,
},
)}
当password
或newPassword
不为空时,我的目标重新验证密码confirmPassword
字段。
const maybeMustBeRequared = (rule, value, callback) => {
console.log('rule', rule)
if (!isEmpty(props.form.getFieldValue('newPassword')) || !isEmpty(props.form.getFieldValue('confirmPassword')) ) {
// there I want trigger passwor field validation { min: 6}
} else {
callback()
}
}
答案 0 :(得分:0)