readState = (state, fields, req) => {
  const read_key = (f, current) =>
    current === "null" || current === "" || current === null
      ? null
      : getState().types[f.reftype].read(current);
  fields.forEach((f) => {
    const current = state[f.name];
    if (typeof current !== "undefined") {
      if (current === "null") state[f.name] = null;
      else if (
        Array.isArray(current) &&
        current.length &&
        typeof current[0] === "object"
      ) {
        //ignore (this is or statement)
      } else if (Array.isArray(current) && f.type.read) {
        state[f.name] = current.map(f.type.read);
      } else if (
        Array.isArray(current) &&
        f.is_fkey &&
        f.reftype === "Integer"
      ) {
        state[f.name] = current.map((v) => read_key(f, v));
      } else if (current && current.slugify)
        state[f.name] = f.type.read
          ? { slugify: f.type.read(current.slugify) }
          : current;
      else if (typeof current === "object") {
        //ignore
      } else if (f.type?.read) state[f.name] = f.type.read(current);
      else if (typeof current === "string" && current.startsWith("Preset:")) {
        const pname = current.replace("Preset:", "");
        if (Object.prototype.hasOwnProperty.call(f.presets, pname)) {
          const preset = f.presets[pname];
          state[f.name] = preset(req);
        }
      } else if (f.type === "File") state[f.name] = current;
      else if (f.type === "Key") state[f.name] = read_key(f, current);
    }
  });
  return state;
}
Read State
@param {object} state
@param {object[]} fields
@param req
@returns {object}