const setVal = (schema, path, val) => {
  const pList = path.split('.'),
        len = pList.length;
  for(let i = 0; i < len-1; i++) {
      let key = pList[i];
      if(!schema[key])
        schema[key] = {};
      schema = schema[key];
  }
  schema[pList[len-1]] = val;
  return schema;
};

module.exports = setVal;