| 99 | * Constructs a path with dot paths for arrays to use brackets to be compatible with vee-validate path syntax |
| 100 | */ |
| 101 | export function normalizeFormPath(path: string): string { |
| 102 | const pathArr = path.split("."); |
| 103 | if (!pathArr.length) return ""; |
| 104 | |
| 105 | let fullPath = String(pathArr[0]); |
| 106 | for (let i = 1; i < pathArr.length; i++) { |
| 107 | if (isIndex(pathArr[i])) { |
| 108 | fullPath += `[${pathArr[i]}]`; |
| 109 | continue; |
| 110 | } |
| 111 | |
| 112 | fullPath += `.${pathArr[i]}`; |
| 113 | } |
| 114 | |
| 115 | return fullPath; |
| 116 | } |
| 117 | |
| 118 | type NestedRecord = Record<string, unknown> | { [k: string]: NestedRecord }; |
| 119 | /** |