我有一個改變口令表格,在下面的結構領域是未註冊時同步錯誤觸發
<Field name={FORM_FIELDS.OLD_PASSWORD} component={FInputField} type="password"
validate={[Validation.required]} />
<Field name={FORM_FIELDS.NEW_PASSWORD} component={FInputField} type="password"
validate={[Validation.required]} />
<Field name={FORM_FIELDS.CONFIRM_PASSWORD} component={FInputField}
type="password" validate={[ Validation.shouldMatch(password)]} />
和shouldMatch功能
export const shouldMatch = (matchValue) => {
return (value) => {
return value !== matchValue ? t('common/validationNotMatch') : undefined
}
};
當我輸入在CONFIRM_PASSWORD字段不匹配,我得到了以下行爲
{ type: '@@redux-form/UPDATE_SYNC_ERRORS', meta: { form: 'changePassword' },
payload: { syncErrors: { confirmPassword: 'common/validationNotMatch' } } }
但是在此行動之後,UNREGIS TER_FIELD動作發生,這使窗體以清除同步錯誤對象
{ type: '@@redux-form/UNREGISTER_FIELD', meta: { form: 'changePassword' },
payload: { name: 'confirmPassword', destroyOnUnmount: true } }
則字段再次
{ type: '@@redux-form/REGISTER_FIELD', meta: { form: 'changePassword' },
payload: { name: 'confirmPassword', type: 'Field' } }
註冊的任何幫助,爲什麼UNREGISTER_FIELD行動發生在這裏?以及如何在出現不匹配時將驗證消息始終顯示出來。