How to run validation on a slice of a redux-form F

2019-04-02 00:56发布

问题:

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!

标签: redux-form