import type { IFieldBase } from "$lib/Models"; export const cleanFormResult = (formResult: IFieldBase, template: any) => { const templateKeys = Object.keys(template); let result = Object.values(formResult.value).reduce((acc: any, curr: IFieldBase, idx) => { return { ...acc, [ templateKeys[idx] ]: curr.value } }, {}); console.log("clean: ", result); return result; }