score:2

Accepted answer
class RaterInviteForm extends React.Component {

  render() {

    const { submitting } = this.props
    return (
      <div className="RaterInviteForm">
        <h1>Invites</h1>
        <form className="form" onSubmit=    {this.props.handleSubmit(validate)}>
          <FieldArray name="emails" component={renderEmails} />
          <div className="form-group">
            <button type="submit" disabled={submitting} className="btn btn-primary">Send Invitations</button>
          </div>
        </form>
      </div>
    );
  }

}

const validate = values => {
  const errors = {}
  console.log('validate')
  if (!values.emails || !values.emails.length) {
    errors.emails = {_error: 'At least one email must be entered'}
  }
  else {
    let emailsArrayErrors = []
    if (emailsArrayErrors.length) {
      errors.emails = emailsArrayErrors
    }
  }
  return errors
}

RaterInviteForm = reduxForm({
  form: 'emailsForm',
  initialValues: {
    emails: ['', '', '']
  }
})(RaterInviteForm)
...

score:1

RaterInviteForm = reduxForm({
  form: 'emailsForm',
touchOnBlur : false 
  initialValues: {
    emails: ['', '', '']
  },
  validate
})(RaterInviteForm)

Related Query

More Query from same tag