score:0

function validate(values) {
  // console.log(values) -> {title: 'asdf', categories: 'asdf', content: 'asdf'}
  const errors = {};

  // validate the inputs from 'values'
  if (!values.title || values.title.length < 3) {
    errors.title = "Enter a title that is at least 3 characters!";;
  }

  // if errors is empty, the form is fine to submit
  // If errors have any properties, redux form assumes form is invalid
  return errors;
}
if (!values.categories) {
    errors.categories = 'Enter some categories';
}
if (!values.content) {
    errors.content = 'Enter some content, please';
}

export default reduxForm({
  validate,
  form: 'PostsNewForm'
})(PostsNew);

Related Query

More Query from same tag