function validateAndSetDefaultStateSingle(
  state,
  field,
  validateFunc,
  setDefaultFunc
) {
  // if `state.field` is valid, don't modify state
  if (validateFunc(state)) {
    return state;
  }
  // otherwise, create new state
  const defaultField = setDefaultFunc(state);
  /* eslint-disable no-console */
  if (process.ENV !== 'production') {
    console.warn(
      `${field} is not valid, resetting to ${JSON.stringify(defaultField)}`
    );
  }
  /* eslint-enable no-console */
  return {
    ...state,
    [field]: defaultField,
  };
}
function to set `state[field]` to a default value if and only if current state[field] value id invalid
@param {Objetct} state - redux state
@param {String} field - field name in `state`
@param {Function} validateFunc - function to decide whether `state[field]` is invalid. Input: state; output: boolean
@param {Function} setDefaultFunc - function to return a default value for `state[field]`. Input: state; output: field value
@return updated redux state

@example
const state1 = {a: {c: 5}, b: 6};
const state2 = {a: {c: 5}, b: 11};
const field = 'b';
const validateFunc = state => state.b >= state.a.c * 2;
const setDefaultFunc = state => 2 * state.a.c;
validateAndSetDefaultStateSingle(state1, field, validateFunc, setDefaultFunc)
// returns {a: {c: 5}, b: 10}
validateAndSetDefaultStateSingle(state2, field, validateFunc, setDefaultFunc)
// returns {a: {c: 5}, b: 11}