Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can redux-form validation based on multiple fields be implemented?

Redux Form validation examples only include individual field validations.

Having a list of a certain number of fields that are the same, how can I model a validation that requires at least one of the inputs to be a valid email address?

For example, for the given form made up of the following fields:

  • User 1,
  • User 2,
  • User 3,
  • Special User 4

How can I write a validation function that requires Special User 4 to always be set, and either one of the first 3 users?

like image 978
Vlad Nicula Avatar asked Oct 29 '15 12:10

Vlad Nicula


1 Answers

Your synchronous validation function is given all the values of the form. Your errors must correspond to a field key, or you can use the generic _error key, which will result in this.props.error being populated.

Does that make sense?

like image 174
Erik R. Avatar answered Sep 28 '22 01:09

Erik R.