How to run validation on a slice of a redux-form FieldArray state

醉酒当歌 提交于 2019-12-05 08:58:13

问题


I am running something very similar to the example here:

http://redux-form.com/6.0.5/examples/fieldArrays/

Say I want to add a list of members and a list of hobbies under each member, like in the example above.

What is different from the example above is, I want to also be able to validate each member, before I am able to add additional members or hobbies for that member.

Similarly, I also want to be able to validate each hobby, before I can add another hobby.

In other words, I want to be able to treat each entry in the FieldArray as a form and each add button as a submit function for that form.

I would have a validateMember and validateHobby validation functions that I would run against the respective FieldArray entries.

I am not aware of any feature of redux-form that allows running synchronous validation on a subset of the form's state. Alternatively, I also cannot treat everything as a form as then I would lose all the nesting (i.e. which hobby belongs to each address).

Any ideas and suggestions are greatly appreciated!

来源:https://stackoverflow.com/questions/39754558/how-to-run-validation-on-a-slice-of-a-redux-form-fieldarray-state

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!