redux-form,提交有错误的表单

redux-form, submit form with an error

我有一个表单,我想在一个字段上显示验证错误(作为用户的信息),但我不希望此错误阻止提交表单。

我将不胜感激任何提示,如何做到这一点...

---编辑---

我被要求提供一个例子。请使用 redux-form 提供的示例:http://redux-form.com/6.6.1/examples/fieldlevelvalidation/

<Field name="username" type="text"
    component={renderField}
    label="Username"
    validate={[ required, maxLength15 ]}
/>

这里有 2 个验证函数:requiredmaxLength15。即使出现 maxLength15 returns 错误消息,我也希望允许用户提交表单。我想显示消息但允许表单提交

如果你想能够提交,那么你应该使用警告而不是错误。否则 redux-form 不会让你提交。

要使用字段级验证来做到这一点,您只需将 validate 属性更改为 warn 属性即可:

<Field name="username" type="text"
    component={renderField}
    label="Username"
    warn={[ required, maxLength15 ]}
/>